How to reflect a bullet back to an enemy who shoots you(in 2d)

Hello to the guys who are using Unity. I’m currently learning Unity and was wondering on how(or if possible)
to do those Ricochet actions(Like when an enemy shoots or throw something at you, you hit it, and it goes straight to the enemy). Any one here knows what i’m talking about? I’m using Unity 5

Store the information which gameobject launched the projectile within the projectile. When the player deflects the projectile you only need to get the current position of the enemy who shoot or has thrown the projectile and then change the direction of the projectile back into the direction of the enemy.

Yes, if you need it to actually go right at the (possibly-moved) enemy, then you have to do as @Verdemis says. Or if you just want it to go back where it came from, then simply invert its velocity.

1 Like

Might help. But I’m completely do not know what I’m doing

Might help if you told us what you are doing. Believe it or not, you only vaguely hinted. Imagine the vast possible ways velocity can be used in a game. How do we know if it’s 2d physics, code or what?

1 Like

Yes, please include details. A bit on what the game is so far. A bit on what game you’re trying to create. A bit on what the player and enemy are doing. A bit on how you think it can be done. If you cannot include code, please include the steps to an algorithm you think up in your head. Algorithmic thinking in game design is good!

Alright. I had an Idea since I was playing zelda ocarina of time last stage when I was fighting ganondorf first battle. Then, I saw that ganondorf was shooting some electric ball and I hit the ball and went back to ganondorf. Then, he hit the ball back to me and once I hit it, it goes back to him(

). If you go to 2:12, You’ll see ganondorf creating a ball and throws it to link. Around 2:14 or 2:15, link hits the ball and goes back to ganondorf.

Plus, im doing this in 2d