Pages: 1
Topic closed
I'm making a top secret game, and I need something to follow the mouse within a certain radius of another object, and when the mouse moves outside that radius, it continues to follow, but without leaving it's designated area.
Sorry if that was confusing I can't really think of how to explain it any other way
Here's the script I have so far:
Note: I have a sprite following the mouse-pointer with a variable called distance.
when green flag clicked
forever
if< [73] > [(distance of mouse-pointer)] >
go to mouse pointer
else
?
I can't think of what to put instead of the ?.
Thanks, and Scratch on!
Offline
You could put in:
go to (other object)
point towards mouse pointer
move (73) steps
And if you want the object to always be facing the right way, just do:
go to (other object)
point towards mouse pointer
move (73) steps
point in direction (90)
Last edited by Kileymeister (2011-06-24 14:00:30)
Offline
Kileymeister wrote:
You could put in:
go to (other object)
point towards mouse pointer
move (73) steps
And if you want the object to always be facing the right way, just do:
go to (other object)
point towards mouse pointer
move (73) steps
point in direction (90)
Hmm... it's still doing the same thing.
@Harakou
Okay!
Offline
Really? I tried it on my program and it does what I expected it to do, maybe I don't understand what you want accomplished.
You want this sprite to go to the mouse pointer when the mouse is a certain distance from a different sprite, right? And when the mouse is too far away, the object circles around to face the mouse pointer, but stays within its maximum allowed distance from the stationary sprite, correct?
And the variable "distance of mouse pointer" is the distance from the stationary sprite to the mouse pointer, not the distance from the moving sprite to the mouse pointer, right?
Last edited by Kileymeister (2011-06-24 14:17:37)
Offline
Kileymeister wrote:
Really? I tried it on my program and it does what I expected it to do, maybe I don't understand what you want accomplished.
You want this sprite to go to the mouse pointer when the mouse is a certain distance from a different sprite, right? And when the mouse is too far away, the object circles around to face the mouse pointer, but stays within its maximum allowed distance from the stationary sprite, correct?
And the variable "distance of mouse pointer" is the distance from the stationary sprite to the mouse pointer, not the distance from the moving sprite to the mouse pointer, right?
Yeah. I think it didn't work (and please forgive me for leaving this out, I thought it would not be important) because it should only follow when it is dragged. I used the if mouse down and mouse-pointer touching script to achieve that Sorry
Harakou wrote:
Oh, one thing: will this other object move or have a fixed position?
Fixed position
Offline
samurai768 wrote:
Harakou wrote:
Oh, one thing: will this other object move or have a fixed position?
Fixed position
Oh, well that makes things a bit simpler for me. What is the position going to be?
Offline
Does this work?
Edit: This one is a bit better:
This one works just as well, but also takes into account displacement between the mouse and sprite (so the sprite doesn't jerk to the mouse's x/y positions when you start dragging it).
Last edited by Kileymeister (2011-06-24 14:46:47)
Offline
Kileymeister wrote:
Does this work?
http://i56.tinypic.com/xmstud.gif
I should think it does, but a more mathematical way would be less glitchy (e.g. if you need to sense something). That's what I'm trying to figure out, and I succeeded theoretically, except it's enormously glitchy.
Offline
Kileymeister wrote:
Does this work?
http://i56.tinypic.com/xmstud.gif
Edit: This one is a bit better:
http://i55.tinypic.com/if1xk2.gif
This one works just as well, but also takes into account displacement between the mouse and sprite (so the sprite doesn't jerk to the mouse's x/y positions when you start dragging it).
That works really well! Thank you!
Offline
samurai768 wrote:
Kileymeister wrote:
Does this work?
http://i56.tinypic.com/xmstud.gif
Edit: This one is a bit better:
http://i55.tinypic.com/if1xk2.gif
This one works just as well, but also takes into account displacement between the mouse and sprite (so the sprite doesn't jerk to the mouse's x/y positions when you start dragging it).That works really well! Thank you!
Aw, just when I was almost done with mine. Oh well, it wasn't working right anyway.
Offline
Harakou wrote:
samurai768 wrote:
Kileymeister wrote:
Does this work?
http://i56.tinypic.com/xmstud.gif
Edit: This one is a bit better:
http://i55.tinypic.com/if1xk2.gif
This one works just as well, but also takes into account displacement between the mouse and sprite (so the sprite doesn't jerk to the mouse's x/y positions when you start dragging it).That works really well! Thank you!
Aw, just when I was almost done with mine. Oh well, it wasn't working right anyway.
Mine was Oh well, I practiced some trigonometry.
Offline
Offline
Topic closed
Pages: 1