How to use PhysicsServer3D.body_test_motion

Godot Version

V4.2.1

Question

I have been scratching my head on how to tell where my character will land before I hit the ground for days now and I think I found a solution but I don’t know how to use it properly.

I think that the PhysicsServer3D method “body_test_motion” will get me the results I want

From what I understand within the method I need to pass a RID, a Motion and then get my result in the form of a Vector3 Collision point (get_collision_point).

What exactly is a RID? I’m assuming its my character or whatever I am moving but not exactly sure how to write it properly
How would I give it my motion? I am assuming my velocity?
And can I use this to tell where my character will land and if so how do you properly write this in gdscript?

If possible a gdscript example of how this method is written would be amazing

To the future people here also in need of help with using this function it’s posible to use by doing it like this

define a PhysicsTestMotionParameters3D varible in the script, and instanciate it in the ready function, or where ever you’re gonna use it and make sure to define the motion property in the PhysicsTestMotionParameters3D .

having done that just pass it into the function like so

PhysicsServer3D.body_test_motion(get_rid(), your_PhysicsTestMotion)

the important part that they dont tell you in the documentation is to keep updating the PhysicsTestMotionParameters3D parameter called “from”. which is where the motion begins from. I recomend updating it just whenever you’re gonna run the function but fell free to do whatever otherwise you will end up having a never changing result from the function.