Dragonfly Q&A

Help with setVelocity()

0 like 0 dislike
My test object moves across the screen without issue when I use setSpeed and setDirection, but there's a problem with my setVelocity(). What is the correct formula to set the speed and direction correctly? I've tried using the vector functions but I think I'm missing something.
Dragonfly version 4.2
asked Sep 18, 2016 in Engine Development by jcscheide

1 Answer

0 like 0 dislike
<p>When doing a setVelocity(), speed is the magnitude of the velocity vector.  i.e, speed = velocity.getMagnitude()

<p>Direction is the velocity vector normalized.  ie., veclocity.normalize(); direction = velocity

<p>When doing a getVelocity(), you scale the direction by the speed.
answered Sep 18, 2016 by claypool
More information about Dragonfly can be found on the Dragonfly Home Page.