Help with JS script [solved]

got scripts? Need scripts?
Post Reply
Shihonoryu
Posts: 255
Joined: Sun Dec 12, 2010 7:30 am

Help with JS script [solved]

Post by Shihonoryu »

Got this error: UnassignedReferenceException: The variable bullitPrefab of 'movearound' has not been assigned.
You probably need to assign the bullitPrefab variable of the movearound script in the inspector.



With this code:

Code: Select all

var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
function Update ()
        {
            var controller : CharacterController = GetComponent(CharacterController);
            transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
            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);
				
			}
			
        }
    @script RequireComponent(CharacterController)

I did assign the bullit prefab in the inspector though. but when i hit space, that error pops up
Last edited by SpiritWebb on Sat Feb 05, 2011 4:47 am, edited 2 times in total.
Reason: poster sent me a message since I sent him the code and then sent another telling me he fixed the problem.
Post Reply

Return to “Scripting/Coding”