Add block to get linear velocity of actor

Epic428

  • Posts: 1118
For the longest time I have wondered why we have a block that lets us manually set the x or y speed of an actor, and then a block that lets us set its actual velocity, but we only have blocks to get the x or y speed of the actor.

There plenty of times where I want to get the actual linear velocity of an object, not the speed in one direction. So perhaps it would be a good idea to add this block.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs


Hectate

  • *
  • Posts: 4643
The Set X/Y speed blocks are a result of Flixel - that is, Flixel can only set X/Y speeds but it can also get them.

The set velocity block is a result of Box2D - that is, Box2D can apply or set a specific amount of force (called a Vector) to an object. Unfortunately, Box2D does NOT have a built-in way to get the velocity of an object for several different reasons. As a result, Stencyl doesn't either. I was looking for the very same thing at one time...

In theory you could get some math put together that would get the linear velocity based on the X and Y speeds though.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

captaincomic

  • *
  • Posts: 6108
I was also wondering why there is no such block. To get the linear velocity use pythagoras' theorem: sqrt(x-speed^2 + y-speed^2). Still would be nice if stencyl wrap this in a block...

Quote from: Epic428
There's a Block for that.
Nope, not this time :)

ShivaFang

  • Posts: 248
Pythagorean theory comes up a lot, both for this and for distances.  It would be great for beginners if this were an implemented block instead of having to make a custom one.

I seem to remember kids in my math classes complaining "When will we EVER use this stuff outside of school?"  Now I look back and laugh.
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!