Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lizistorm | |
Old Version | Published before Godot 3 was released. |
In my case I want to get the position the ball(RigidBody2D) contact with the wall(StaticBody2D).
Can’t find solution in document and google search. Anyone know how to do this here? Thanks!
I finally found the solution. Use Physics2DDirectBodyState in _integrate_forces callback with RigidBody2D to get the collision position:
func _integrate_forces(state):
state.get_contact_local_pos(0)
lizistorm | 2016-04-02 00:31
When I try using this, it tells me that this function doesn’t exist, was this function removed in an update or something else?
LaranjoLouco | 2020-10-15 19:30
oh lol, i just copied the code and i forgot to change “pos” to “position”
LaranjoLouco | 2020-10-15 19:32
when i try this, i get this error “E 0:00:01.042 get_contact_local_position: Index p_contact_idx = 0 is out of bounds (body->contact_count = 0).”
LaranjoLouco | 2020-10-15 19:55
Oh, i forgot to set the contacts reported higher than 0
LaranjoLouco | 2020-10-15 21:05