i’ve been trying to make this script and im stuck, im trying to get my little sphere to shoot a fireball but it spawns it but doesn’t shoot out and then i get this error.
object reference is not set to an instance of an object
and
an instance of type unityengine.transform is required to access non static member forward.
anyways heres the script.any help would be greatly appreciated
var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move Forward / backward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitPrefab,
GameObject.Find("spawnPoint").transform.position,
Quaternion.identity);;
bullit.Rigidbody.AddForce(Transform.forward * 2000);
}
}
@script RequireComponent(CharacterController);