I have an Area2D bullet that has a direction and a speed and a TileMap with a collider. When this bullet hits the side of the TileMap I want the bullet to bounce off it (change the direction).
I need to get the normal of the collision with the TileMap
Like this but I need a normal:
func _on_body_entered(body):
direction = direction.bounce(normal)
An Area2D does not detect collisions. Only detects overlaps and has no information about where the overlap happened. You’ll need to use the ``PhysicsDirectSpaceState2D to query the physics server and get more information about the overlap.
Hi! I see you marked this as resolved, but I’m trying to do something simillar (getting the angle of collision between an Area2D and a Tilemap) and I can’t figure the thing out
If you solved this, could you help providing an example of how you did it?
var collision_object = move_and_collide(linear_velocity * delta)
if collision_object:
if collision_object.get_collider() is TileMap:
linear_velocity = linear_velocity.bounce(collision_object.get_normal())
Btw my bullet is a rigidbody 2d with an initial velocity.
Hope this helps
sry for the late reply.
Didn’t use the other method lol.