Hi can I have some guide on the jumping script below? I attached it to my player but whenever I press on space, the character does not move at all…
using UnityEngine;
using System.Collections;
public class Jumping : MonoBehaviour {
private bool isJumping;
private Vector2 force;
// Use this for initialization
void Start () {
isJumping = false;
force = new Vector2 (0.0f, 0.2f);
}
// Update is called once per frame
void Update () {
//Button of choice to jump
if(Input.GetKey(KeyCode.Space))
{
if(isJumping == false)
{
rigidbody2D.AddForce (force);
isJumping = true;
}
}
}
void OnCollisionEnter2D(Collision2D col)
{
//The floor is tagged as Ground
if (col.gameObject.tag == "Ground")
{
//Logs to console, to check if working. *No problem here
Debug.Log ("Working!");
isJumping = false;
}
}
}