• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Precise Collision Check (x,y)

Greetings,

I'm making a boss for my game and that boss launches a fireball and this fireball moves towards the coords thats given when fireball is created and the coords gets determined by creating an object on top of the player. (It just gets it :p)

The problem is,
I want to get a return when the fireball collides with the explosion marker object's middle, or we can say x and y's of it right?
 

Attachments

jo-thijs

Member
I case you're familiar with how to use code, you can use the function position_meeting(x, y, object) for this.
 
I case you're familiar with how to use code, you can use the function position_meeting(x, y, object) for this.
I've tried many ways but here is what I've got

Code:
//STEP EVENT of Fireball 
var hit = position_meeting(objBossMageLaserBeam.closestenemy.x,objBossMageLaserBeam.closestenemy.y,objBossMageIonBallHitMarker) //These x and y coords are the coords of objBossMageIonBallHitMarker

if (hit)
 {
  objBossMageIonBallHitMarker.image_speed=1;
  instance_destroy();
 }
this code teleports the fireball to the hit marker and I don't want it to teleport :)
 

jo-thijs

Member
You don't want to check if the marker collides with the middle of the marker,
you want to check if the fireball collides with the middle of the marker.

Change the third argument of position_meeting to the variable: id
 
Fireball just passes through the marker

Code:
//Step Event of Fireball
var hit = position_meeting(objBossMageLaserBeam.closestenemy.x,objBossMageLaserBeam.closestenemy.y,id)

if (hit) {
  objBossMageIonBallHitMarker.image_speed=1; //IonBall = Fireball :P
  instance_destroy();
 }
 
Last edited:

jo-thijs

Member
Are you sure you're using the correct x and y coordinates?
Are you also sure the fireball goes slow enough to not teleport over the spot?
Is there any other relevant code?
 

jo-thijs

Member
Sounds to me like you actually want to use this:
Code:
//Step Event of Fireball
var hit = position_meeting(objBossMageIonBallHitMarker.x,objBossMageIonBallHitMarker.y,id)

if (hit) {
  objBossMageIonBallHitMarker.image_speed=1; //IonBall = Fireball :P
  instance_destroy();
 }
Do you destroy the generated hit markers when they're no longer necessary?
 
Yep, that worked as I wanted and..yes I do destroy them within the animation end function. I kinda know thats not good to do but I just do it like that. You have any idea for it?
 
Top