admin管理员组

文章数量:1401149

I'm making a simple 2D space shooter game like asteroids in Godot. The characterbody2D (the ship) floats in space until it hits a wall (a staticbody2D)- this will be the only thing it collides with. I'm using move_and_collide(), and a simple bounce script on collision.

I want to implement a system that detects the force of the collision, and punishes the player based on just how strong the collision was. Low speed collisions shouldn't count, but high speed collisions at a steep angle should. I can't just use the velocity of the player before impact, as the collision might have been just a slight glance off a wall at high speeds. I need to find a way to access Godot's understanding of the collision- if there is some way to get the impulse created by the characterbody in a collision, that would be perfect. Otherwise, I may have to learn some math and find the right way to calculate the balance between velocity and angle of impact...

I learned about kinematiccollision2D, but none of the accessible info in it helps me get the impulse created on impact, only the angle and the velocity before and after. I hope I'm missing something here, please help :)

本文标签: Godot How do i get the impulse on collision for a characterbody2DStack Overflow