Using Bullet's _fireDirection for IDamageable can pull instead of push

With the refactor to IDamageable in this lecture we use the _fireDirection Vector2 which is passed through to Knockback. For me this sometimes pushes enemies in the expected direction, the one the bullet is travelling in, and at other times it instead pulls the enemies toward the bullet’s origin point. At first I thought it was dependant on which direction the player was facing, that it might be due to changing the player’s rotation. With further testing that doesn’t seem to be the case, it seems like it depends on the enemy’s position in the world more than anything else.

The issue is almost definitely to do with using _fireDirection, replacing it with PlayerController.Instance.transform.position or the bullet’s transform.position works perfectly fine. I just can’t figure out the why of it, or if anyone else has experienced this behaviour.

Yeah, I get this. I think it happens mainly when an enemy drops down onto a bullet that is almost past it (eg the player shoots under the enemy and it then lands ON the bullet). At this point, the bullet is on the opposite side of the enemy than the player.

1 Like

Privacy & Terms