Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | KenjiGlove |
Hey everyone,
I’ve got a ball, which bounces around like in a game of snooker. It detects colissions via the following signal:
func _on_Ball_body_entered(_body):
print ("Boing~!")
Besides printing "Boing~!, I’d also like to know the exact position of the collission. I want to know this because I want to play an explosion animation at the collision point whenever the ball bounces against something.
It seems simple, but I’ve been searching around the web for a while without result, The closest I got was this:
func _on_Ball_body_entered(_body):
print ("Boing~!")
print ("CurrentPosition", get_position())
var p =Physics2DTestMotionResult.new()
test_motion(get_position(), true, 1, p)
var ColissionPoint = p.get_collision_point()
print ("ColissionPoint =", ColissionPoint)
Which gives bugged results depending on the angle of the collision. It works fine if you bounce against something on the right:
But whenever you bounce against something to the left, it thinks you’ve bounced against something unrelated on the right instead.
There has to be an easier and accurate way to get a colission position at any rate.
Please help me out bros!
Thanks in advance.