I don't know what im doing wrong and aparently you get this error when you don't use the variable but im using it multiple times in my script.
using UnityEngine;
using System.Collections;
public class Jump : MonoBehaviour
{
private bool OnGround;
private Rigidbody rb;
void Start()
{
OnGround = true;
rb = GetComponent();
}
void Update()
{
if(OnGround)
{
if (Input.GetButton("Jump"))
{
rb.velocity = new Vector3(0.0f, 10f, 0.0f);
}
else
{
rb.velocity = new Vector3(0.0f, 0f, 0.0f);
OnGround = false;
}
}
}
void OnCollisonEnter(Collision other)
{
if (other.gameObject.CompareTag("ground"))
{
OnGround = true;
}
}
}
↧