I'm just trying to see if my idea should work or if I'm doing something wrong. I have a sprite with the bullet behavior that moves towards where the mouse was clicked. I'm trying to get the sprite to stop when it reaches where the mouse clicked. Sadly , it won't stop. Here's what I have. I am using version 0.99.62.
right mouse button clicked
sprite: set speed to 250
sprite: rotate 360 degrees towards (MouseX, MouseY)
System: set global variable 'mousex' to MouseX
System: set global variable 'mousey' to MouseY
sprite: Y Equal to global('mousey')
sprite: X Equal to global(mousex')
sprite: set speed to 0
Also, if anyone has an idea for how to select certain troops and unselect them once they have been assigned to do something it would be great. Thanks .
Edit: I scrapped the variables and instead am using another sprite that goes to where the mouse right clicked. That part works fine now. I'm just wondering if there's anyway to make an object selectable and unselectable.
Edit: I used private variables for determining whether an object was selected (tell me if there's a better way please). Right now, I'm wondering if there's a way to use custom movement to make an object move towards a position without using rotation. Thanks .
Edit: I found a way to do it without using custom movement, though I would still appreciate it if someone could explain a way to use it for this purpose. Instead, I used a sprite that had the bullet behavior and set the position of the first sprite to the second so that the first sprite wouldn't rotate. For anyone interested, here's the code that shows how I did it all.
sprite1 is a stickman, 'selected' is a private variable for stickman, rotating_sprite is a point whose opacity is 0 and has the bullet behavior, stop_sprite is a small box whose opacity is also set to 0, mouseandkeyboard object is used
on left clicked on sprite1
=> sprite1: set 'selected' to 1
on left mouse button clicked
=> sprite1: set 'selected' to 0
on right mouse button clicked
sprite1: Value 'selected' Equal to 1
stop_sprite: set position to (MouseX, MouseY)
rotating_sprite: set angle towards stop_sprite
rotating_sprite: set speed to 250
on collision between rotating_sprite and stop_sprite
rotating_sprite: set speed to 0
sprite1: set position to rotating_sprite.X, rotating_sprite.Y
Sorry for all the edits, I made some mistakes and had to fix them.