Quantcast
Viewing latest article 1
Browse Latest Browse All 115

[Answered](C#) Unexpected symbol `else' Need Help

Hello everyone. I am making a movement script with some animations(first time) and I am getting errors that don't make sense to me. The first error I am getting is "PlayerMovement.cs(48,28): error CS1525: Unexpected symbol `else". I have never really used else before so I am guessing it is a noob mistake(Sorry if it is) the other error I am getting is "PlayerMovement.cs(70,1): error CS8025: Parsing error" This does not make sense to me either...I am guessing it has to do something with the other error?? Here is my script using UnityEngine; using System.Collections; public class PlayerMovement : MonoBehaviour { //Public public float WalkSpeed = 5f; public float RunSpeed = 10f; public float JumpSpeed = 9.8f; public float Gravity = 25f; //Private private bool Grounded; private bool Running; private float OriginalSpeed; private Vector3 moveDirection= Vector3.zero; private CharacterController Controller; // Use this for initialization void Start() { Controller = GetComponent(); OriginalSpeed = WalkSpeed; } // Update is called once per frame void Update() { grounded = ((flags & CollisionFlags.CollidedBelow) != 0); if(grounded) { moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= WalkSpeed; if(Input.GetKeyDown(KeyCode.Space)) { moveDirection.y = JumpSpeed; } if(Input.GetKey(KeyCode.LeftShift) && (Input.GetAxis("Horizontal")) || (Input.GetAxis("Vertical"))); { moveSpeed = RunSpeed; running = true; } else { running = false; WalkSpeed = OriginalSpeed; } if(controller.velocity.magnitude > (WalkSpeed - 1) && controller.velocity.magnitude < (RunSpeed - 1)) { animObj.animation.CrossFade("Walk"); } else if(controller.velocity.magnitude > (RunSpeed - 1)) { animObj.animation.CrossFade("Run"); } else { animObj.animation.CrossFade("Idle"); } } } }

Viewing latest article 1
Browse Latest Browse All 115

Trending Articles