Question by
Harigan · Jul 16, 2017 at 05:52 PM ·
errorunexpected-symbol
Error Unexpected Symbol ';' expecting ')' or ','
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerController : MonoBehaviour {
public float moveSpeed;
public float jumpForce;
private Rigidbody2D myRigidbody;
public bool grounded;
public LayerMask whatIsGround;
private Collider2D myCollider;
private Animator myAnimator;
// Use this for initialization
void Start () {
myRigidbody = GetComponent<Rigidbody2D> ();
myCollider = GetComponent<Collider2D> ();
myAnimator = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
grounded = Physics2D.IsTouchingLayers (myCollider, whatIsGround);
myRigidbody.velocity = new Vector2 (moveSpeed, myRigidbody.velocity.y);
if(Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) )
{
if (grounded) {
myRigidbody.velocity = new Vector2 (myRigidbody.velocity.x, jumpForce);
}
}
myAnimator.SetFloat ("Speed", myRigidbody.velocity.x;
myAnimator.SetBool ("Grounded", grounded);
}
}
Comment
Answer by tanoshimi · Jul 16, 2017 at 05:53 PM
Please look at the line number given in the error message. It will tell you exactly where your error is:
myAnimator.SetFloat ("Speed", myRigidbody.velocity.x;