GameMaker a simple boomerang-ish projectile

V

Viggar

Guest
hello, I've stumbled on a problem that seems really simple, but I can't wrap my head around it.

I want to make a simple object that returns to the player after it flies a certain distance or hits a wall, but the collision is always inconsistent and it bounces off the walls like ping pong.

this is the code for the player step event:
{
var box, ID;
if image_xscale == 1
box = bbox_left;
else
box = bbox_right;

ID = instance_create (box+image_xscale*6, y+2, obj_pizza)

ID.hsp = image_xscale * 6;
isShoot = true;
alarm[0] = 20;
}

and the create and the alarm [0] event code:
// throwing
isShoot = false;
 

curato

Member
I think the code in obj_pizza is what we would need to see if is launching and not coming back as expected
 
V

Viggar

Guest
I think the code in obj_pizza is what we would need to see if is launching and not coming back as expected
oh right, here it is:

direction = point_direction(x, y, obj_player.x, obj_player.y);
speed = 2;

if (place_meeting(x, y, obj_player))
{
instance_destroy();
}
 

curato

Member
Is that everything? seems like you are missing stuff we need to see everything and which event it is in to figure out why it isn't behaving as expected.
 

curato

Member
I would use something like
Code:
if distance_to_object(obj_Player) < theshold // theshold would have a small distance that is tollerable to count as good enough
{
     instance_destroy();
}
 
Top