[Solved] Physics: how to read Sprite speed?

I am trying the physics model. So I added physics behaviour to two of my sprites, and it already works that I can move the player sprite as expected and hit another sprite. Now I’d like to display the speed of the player sprite in a text object.

What is the formula to generate the text with? In an unconditional event I want to access the player sprites speed, and Player.ForceLength() seems to be always zero. I guess somehow I need to ask the physics engine about the linear velocity but how do I correctly enter this in the field to evaluate the new text string?

To visualize where concisely I am stuck here two screenshots. I want to display the speed of the sprite Boat, which has Physics behaviour.

After entering the sprite name, GDevelop offers Physics2. So far so good…

GDevelop-Physics

…but as soon as I choose this to continue, I am left here

GDevelop-Physics2

…and I have no clue what to enter next to actually get the Boat’s physics properties like speed.

Again I can answer my own question. After searching the wiki pages for whatever hints I found this chapter: Expressions reference [GDevelop wiki]

And tadaaaa - this expression worked both for the text display and later in a condition to see if the boat collides too fast:
Boat.Physics2::LinearVelocity()

2 Likes