- Home /
how do i fix this code error BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'rotation'.
this is the script help
var speed:float = 6.0;
var jumpSpeed = 8.0;
var gravity:float = 20.0;
private var moveDirection:Vector3 = Vector3.zero;
function Update(){
var controller:CharacterController = GetComponent(CharacterController);
if(controller.isGrounded){
moveDirection = Vector3(0,0,Input.GetAxis("Horizontal"));
moveDirection *= speed;
if(moveDirection.sqrMagnitude > 0.01)
transform.Rotate = Quaternion.Slerp(Transform.rotation,Quaternion.LookRotation(moveDirection),1);
if(Input.GetButton("jump")){
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
tell me how to fix it or fix it for me plz!!!!
Answer by rutter · Mar 30, 2012 at 01:26 AM
This: Transform.rotation
Needs to be this: transform.rotation
Transform
is a class; transform
is a reference to an object of type Transform
. The two are related, but are not the same thing.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Script not working (Java script) 2 Answers
Access components in ALL children 1 Answer
Official Unity Space Shooter Tutorial 1 Answer
"Absolute URI is too short" woe 1 Answer