Simple C# script to move a gameObject toward the direction of the player at the instance of it's spawning.

Hello :slight_smile:

I am currently developing a little 2D project of mine, and to put it in simple terms, I have an enemy that fires a gameObject when it is within a certain distance of the player. I have created the projectile as a trigger-able prefab and was having trouble figuring out how to make the object not follow the player, but move in the direction that the player was in upon it’s spawning. (As a separate script)

In the below script, what would I have to replace ‘left’ with?

void Update () {
		transform.Translate(Vector3.forward * Time.deltaTime);
		transform.Translate(Vector3.left * Time.deltaTime, Space.World);

Make a Vector3 variable in the class and get player position in Start() function. Use that to go to where the player was on spawn.