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!" );
}
}