This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm trying to measure the force applied to one RigiedBody2D to another. Is there a function for this or is it just a question of vector math? in witch case a hint about what that type of math is called would be apreaciate

in Engine by (38 points)

1 Answer

+1 vote

As far as I can tell there aren't any queries in the script to directly get the impact values from the solvers.

If you're wondering about the math, RigidBodies generally use inelastic collisions formulas, where the masses exchange velocities along a collision normal. There's a so so article on it here at Gamasutra: http://www.gamasutra.com/view/feature/131424/pool_hall_lessons_fast_accurate_.php?page=3

A possible solution to your problem that may be worth testing is just monitoring the length (magnitude) of the velocity vector of your chosen object. After a collision compare the difference in length. If it loses force it's velocity magnitude should shrink, if it gains force, then the magnitude will grow.

Depending on the frame timing, the difference between the current and previous velocity magnitude might answer that question.

by (5,286 points)

Physics2DDirectBodyState may help to get some information for calculations with get_contact_collider_velocity_at_pos
http://docs.godotengine.org/en/stable/classes/class_physics2ddirectbodystate.html#class-physics2ddirectbodystate-get-contact-collider-velocity-at-pos

There is the Physics2DTestMotionResult too but I don't know how it is used.

Just one correction: that's called an elastic collision. You get an inelastic collision when the colliding objects deform and stay deformed like bags of sand.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.