Topic was automatically imported from the old Question2Answer platform.
Asked By
samort7
I have an Area2D bullet colliding with a KinematicBody2D zombie. The zombie has a CircleShape2D collision shape.
What is the best way to locate the point on the circle opposite the bullet so that I can spawn a blood particle effect?
Here’s an illustration of what I am trying to do:
Maybe calc a point which is a continuation of the bullets path with a distance of the shapes maximum width (maybe slightly longer) then from there do a raycast2d in the opposite direction. (back).
If you have the direction Vector2 of the bullet, you get the distance Vector somehow like: Direction.normalized()*ShapeWidth.
May fail if another shape is very close (raycast will hit that instead).
Maybe too complicated & there’s a much easier way, therefore only as comment.
Is there a way to get the angle of impact for a CircleShape2D?
samort7 | 2019-11-14 23:46
The ‘angle of impact’ will be the bulletAngle described above. hitAngle describes the point on the circle’s radius the bullet hit, bulleAngle is the angle the bullet hit it at. Edit: converted vars from snake-case to camel-case as this forum seems to have serious issues with underscores
thirite | 2019-11-15 08:23
Been working on this for a couple days now. Just not sure how to get hitAngle and bulletAngle. Any tips?
samort7 | 2019-11-18 05:04
When the bullet hits an actor, take the position of the actor and find the angle to the position of the bullet. That will be the hitAngle.
eg: var hitAngle = actor.position.angle_to(bullet.position)
bulletAngle will then literally be the angle of the bullet’s velocity.
eg: var bulletAngle = bullet.velocity.angle()