• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

player movement problem

X

Xecries

Guest
Hi Guys,

I made a top down shooter for an android game and my player follow the mouse / finger. My problem is everytime i want to click the missile button the plane will also move from its current position towards the button. This is how i code my player.

Step Event:
execute code:

if(instance_number(MouseClick) =1)
{
move_towards_point(MouseClick.x,MouseClick.y,5);
if(distance_to_point(MouseClick.x,MouseClick.y)<5)
{
with MouseClick instance_destroy();
speed = 0;
}
}

Mouse Event for Glob Left Button:
execute code:

with MouseClick instance_destroy();
instance_create(mouse_x,mouse_y,MouseClick);


and here i code my Missile button

Mouse Event for Left Released:
for all Player: create instance of object Seeker at relative position (0,0)
Sorry if my english is not good. Thanks

 
A

Azure Spectre

Guest
You will want to add a condition to the mouse click object being created.

Something along the lines of:

Code:
if !position_meeting(mouse_x,mouse_y,obj_missilebutton)
{
    with MouseClick instance_destroy();
    instance_create(mouse_x,mouse_y,MouseClick);
}
 
X

Xecries

Guest
You will want to add a condition to the mouse click object being created.

Something along the lines of:

Code:
if !position_meeting(mouse_x,mouse_y,obj_missilebutton)
{
    with MouseClick instance_destroy();
    instance_create(mouse_x,mouse_y,MouseClick);
}
okay i will try this. thanks
 
X

Xecries

Guest
Hi and Thanks Azure.

if position_meeting(mouse_x,mouse_y,Fire_SeekerX)
{
with MouseClick instance_destroy();
}

i change the code a bit and it works. thank a lot!!!!! finally i can continue with my project.
 
Top