I am following a tutorial and I don’t know if it’s because I have the newer version or I did something incorrectly. (I realized some of the scripts were not valid in the updated Unity.)
I can constantly hit the space bar and my character will continue to jump.
I tried making an ‘Empty Child’ but it didn’t recognize that I placed with the player.
I have no clue how to fix this issue.
using UnityEngine;
using System.Collections;
public class Rose_Contoller : MonoBehaviour {
public Transform groundCheck;
public float groundCheckRadius;
public LayerMask WhatIsGround;
private bool grounded;
public float moveSpeed;
public float jumpHeight;
// Use this for initialization
void Start () {
}
void FixedUpdate () {
grounded = Physics2D.OverlapCircle(groundCheck.position,groundCheckRadius,WhatIsGround);
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Space)){
GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x,jumpHeight);
}
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,0);
}
}
}