Im very new to Unity (literally started today) and i started following gamesplusjames’s tutorial for a 2d platformer. So far everythting went well and i solved some problems by looking at already existing threads but i can’t seem to figure this one out. as i said in the title it’s a paring error.
public float movespeed;
public float jumpheight;
public Transform groundCheck;
public float groundCheckRadious;
public LayerMask whatIsGround;
private bool grounded;
private bool doubleJumped;
// Use this for initialization
void Start () {
}
void FixedUpdate () {
grounded = Physics2D.OverlapCircle (groundCheck.position, groundCheckRadious, whatIsGround);
}
// Update is called once per frame
void Update () {
if (grounded)
doubleJumped = false;
if (Input.GetKey (KeyCode.D)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.GetKey (KeyCode.A)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (-movespeed, GetComponent<Rigidbody2D>().velocity.y);
}
if (Input.GetKeyDown (KeyCode.Space) && grounded)
{
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, jumpheight);
doubleJumped = true;
{
GetComponent<Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeRotation;
}
{
if (Input.GetKeyDown (KeyCode.Space) && grounded (!doubleJumped && !grounded))
;
} (it says the problem is here)
}