HOw can i fix this error??
var walkAcceleration : float = 5;
var cameraObject : GameObject;
var maxWalkSpeed : float = 20;
@HideInInspector
var horizontalMovement : Vector2;
function Update ()
{
horizontalMovement = Vector2( rigidbody.velocity.x, rigidbody.velocity.z);
if (horizontalMovement.magnitude > maxWalkSpeed)
{
horizontalMovement = horizontalMovement.normalized;
horizontalMovement *= maxWalkSpeed;
}
rigidbody.velocity.x = horizontalMovement.x;
rigidbody.velocity.z = horizontalMovement.y;
transform.rotation = Quaternion.Euler(0,cameraObject.GetComponent(MouseLookScript).currentYRotation,0);
rigidbody.AddRelativeForce(Input.GetAxis(“Horizontal”) * walkAcceleration, 0, Input.GetAxis(“Vertical”) * walkAcceleration);
}
Firstyoushouldformatthecodeasthisisunreadable. Use 101 010 button.
– LovrencI'm looking forward to when these forum API's will automatically format code.
– Next_Beat_GamesStart by finding out which object is null.
– andymadsIf you double click on the error in the console window it will bring up your code with the line the error is on highlighted. It will be a variable on that line that is initialized properly.
– robertbuDo you have a rigidbody component?
– FL