Instantiate projectile rotation

So yeah this seems to be a common problem and I haven’t gotten any wiser after a few hours of trying things out. The fireballs fly in all the wrong directions and I have no idea why :slight_smile:

using UnityEngine;
using System.Collections;

/// <summary>
/// Create fire ball.
/// This script is attached to the player and instantiates a fireball when "Attack" is pressed.
/// </summary>

public class CreateFireBall : MonoBehaviour {
	public GameObject fireBall;
	Transform playerTransform;
	Vector3 firePosition;
	Quaternion playerRotation;

	// Use this for initialization
	void Start ()
		//if(networkView.isMine == true)
			playerTransform = transform;
			//enabled = false;
	// Update is called once per frame
	void Update ()
		//mouse 0
			//In front of the player?
			firePosition = playerTransform.TransformPoint(0,0,0.2f);
			//what the f---?
			playerRotation = Quaternion.Euler(playerTransform.eulerAngles.x + 90f, playerTransform.eulerAngles.y, playerTransform.eulerAngles.z);
			//call the function to instantiate the fireball
			fire (firePosition, playerRotation);
			//networkView.RPC("fire", RPCMode.All, firePosition, playerRotation);
	void fire(Vector3 position, Quaternion rotation)
		Instantiate(fireBall, position, rotation);

It’s bizarre that you’re messing with the player’s rotation like that. What view is the game being played from? If first person, just use camera.transform.forward. If top-down, use the player’s forward vector.

Oh my god I fixed it. I added Space.World to the projectile’s script like this
transform.Translate(transform.forward * speed * Time.deltaTime, Space.World);
I’ve been debugging this for like 12 hours I’m amazed I didn’t kill anyone yet :o Is it always like this when running into problems? Even after you have some/a lot of experience in Unity?