We're constantly trying to make Phaser 3 better
I am working on an example to learn the Phaser Engine. I use Pong as an quick hello world when I am learning a new game engine due to its simple rules, multiplayer/single with simple ai, score keeping, and win conditions.
One thing I would like to do is get the Vector2 that is used for the velocity so I can tell which way the ball was traveling when a score happens. There currently doesn't seem to be a way to do this. Am I missing this or is this really a missing feature from the API.
[Optional] Do you want to help provide this feature?
I would like to help contribute this if it is a missing feature. It looks like adding a getVelocity method to the Velocity component would be the most straight forward way. Thoughts?
Hi, I assume you're using Arcade Physics? If so, the velocity can be obtained from Sprite.body.velocity.
That worked.
Okay, swear I dug though the debugger looking for exactly that, but I missed it. I am just getting started with phaserjs and I was surprised that this was "missing"
Thanks for the quick response.
Wouldn't be much use if it was missing :)
Arcade.Sprite had "set" methods, but dont have "get" methods =(
I preffer use method calls instead getting property by myself.
I think this would be better to implement getters to this components.
Most helpful comment
Hi, I assume you're using Arcade Physics? If so, the velocity can be obtained from
Sprite.body.velocity.