Fireball Script not moving in a straight line

Hi I’m new to coding and I can’t figure out why my fireball isn’t going straight. Here’s the script:

using UnityEngine;
using System.Collections;

public class Fireball : MonoBehaviour {
private Transform _forward;

private Vector3 _moveDirection;
private CharacterController _cc;

private float _fireballSpeed = 15f;
private Transform _myTransform;
private float _lifespan = 10f;  
private int _damage;

void Awake() {
	_myTransform = transform;
}

// Use this for initialization
void Start () {
	_damage = 10;
}

// Update is called once per frame
void Update () {
_myTransform.position += _myTransform.forward * _fireballSpeed * Time.deltaTime;
_myTransform.rotation = new Quaternion( 0, 0, 0, 0);

   _lifespan -= Time.deltaTime;
   if(_lifespan < 0)
   {
    Destroy(this.gameObject);
	Debug.Log( "Time destroying!" );
   }
}

void OnTriggerEnter(Collider other)
{      
    Destroy(gameObject);
	Debug.Log( "Destroying!" );
}	

}

The problem is Quaternion(0,0,0,0), which doesn’t work as a rotation. Use Quaternion.identity (for a rotation, the sum of the 4 numbers have to be one, since you want a normalized quaternion).

Why are you storing _myTransform = transform; in Awake()? Instead:

void Update()
{
transform.position= (etc etc)
}

Are you using a rigidbody on the object,if so make sure you have gravity switched off :slight_smile: