- Home /
nullreference exeptio, object reference not set to an instance of an object
i want to create a simple raycast but i get this error?! my code: var speed : float = 5; var moveDirection : Vector3 = Vector3.zero; var senstivity : float = 5; var mouseX : Vector3; var grounded : boolean; var inAir : boolean; function Update(){ } function FixedUpdate(){ if(Physics.Raycast(transform.posistion,-transform.up,2.0 )){ } Move(); Rotate(); } function Move(){ if(Input.GetAxis("Horizontal") || Input.GetAxis("Vertical")){ moveDirection = Vector3(-Input.GetAxisRaw("Horizontal"),moveDirection.y, -Input.GetAxisRaw("Vertical")); this.transform.Translate(moveDirection.normalized * speed * Time.deltaTime); } } function Rotate(){ if(Input.GetAxis("Mouse X")){ mouseX = Vector3(mouseX.x,Input.GetAxis("Mouse X"),mouseX.z); this.transform.Rotate(mouseX.normalized * senstivity * Time.deltaTime); } }
please help because i have tried all i know and searched the whole internet
Answer by chelnok · May 08, 2013 at 01:08 PM
You got just a small typo: Physics.Raycast(transform.posistion
posistion -> position
btw you should use code tag for your code (its that 101010 button)
ahhh realy? i'm so dumb :/ thanks for your help! and i clicked that but i think it was typed outside of that. thanks :)