Here’s my script:
public float walkAcceleration = 5f;
public GameObject cameraObject;
public float maxWalkSpeed = 20f;
private Vector2 horizontalMovement;
void Start () {
}
void Update () {
horizontalMovement = new 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 = new Quaternion.Euler(0, cameraObject.GetComponent<PlayerLookScript>.currentYRotation, 0);
rigidbody.AddRelativeForce(Input.GetAxis("Horizontal") * walkAcceleration, 0, Input.GetAxis("Vertical") * walkAcceleration);
}
Here are my errors:
Assets/Scripts/PlayerMovementScipt.cs(25,53): error CS0426: The nested type Euler' does not exist in the type
UnityEngine.Quaternion’
Assets/Scripts/PlayerMovementScipt.cs(23,27): error CS1612: Cannot modify a value type return value of `UnityEngine.Rigidbody.velocity’. Consider storing the value in a temporary variable
I know this is pretty simple but I cannot figure it out! Thanks! (BTW I was following a tutorial but it was written in Javascript and I prefer c# so I tried translating it over and this is what I got. Thanks)