Actor's movement increases score
What is the best way to have the score attribute increase with an actor's movement in all direction?
Please explain in depth.
Thanks!
Please explain in depth.
Thanks!
![:D :D](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/grin.png)
Best Answer
-
Rob2 Posts: 2,402
Constraining to mouse is just seeing the mouse position so no velocities calculated I'm afraid.
You will have to do a series x,y samples and just calculate lots of magnitudes over time to get an idea of distance travelled if thats the way you want to go.
OR...you could conceivably make a net of three actors (triangle) constrained to mouse place your actor inside and push it around with collision from the triangle - that would register velocity!! - but is a little bonkers
Answers
If this isn't the answer you are looking for, please just say.
I actually already have the score increasing with time, but I am also wanting the score to increase with the actor's movement on the scene, and yes it is somewhat of an endless runner game.
with touch?
demo: http://www.mediafire.com/?f99nn7em6j39sbu
then window changed to "We're overloaded… "
then posted twice!
weird!
[GS measures speed in pixels/second]
If your actor is very lively you will need to sample more often to improve accuracy and adjust your total accordingly. You could say sample every .1s and just divide you total by 10.
This will only work if velocity is being driven by physics or move/move to/accelerate etc. Interpolate and mouse/touch does not effect velocity.
edit: you can also use magnitude( linear velocity.X , linear velocity.Y ) to get speed - its basically performing the same calculation and I guess is more straightforward - but seeing the real math is good
The actor moves by being touch and dragged around the scene.
Thanks for the awesome demo!
Thanks for the help!
Thanks for the detailed explanation!
You say this technique will only work if velocity is being driven by physics or move/move to/accelerate etc, and that Interpolate and mouse/touch does not effect velocity. But does it work with an actor's movement caused by an x and y's constraint attribute of the position to the mouse position?
Thanks for the help!