I’m having some trouble make a projectile face the target/player on instantiation. Since it’s a topdown, I want it’s y position to be at 4 and it’s look at for the y position to be always 0 to make sure its going forward and not up or down.
The moving toward player seems to work properly as the sphere represents its position but the pointed cube is not facing the player.
Instantiation:
Vector3 spawnOffSet = transform.position + Vector3.up * 3f; //This is where the mouth of the raptor is
projectileScript newProjectile= Instantiate(projectile,spawnOffSet,Quaternion.identity);
newProjectile.InitiateProjectile(target.position-spawnOffSet,projectSpeed,this.tag); //Pass tags to function.
InitiateProjectile to face target and move tward it.
public void InitiateProjectile(Vector3 targetPos,float newSpeed,string origin){
targetPos.y = 0; //Make sure that the projectile stays on its current y axis
transform.LookAt(targetPos); //Rotate to the target
moveDirection = targetPos; // Move to the target;
}