I'm currently trying to build a simple demo where the player can jump. This is the script I have setup so far.
using UnityEngine;
using System.Collections;
public class PlayerJump : MonoBehaviour
{
public Vector3 jumpForce;
void OnCollisionStay (Collision other)
{
print("OnCollisionStay");
if (Input.GetKey (KeyCode.Space) && other.gameObject.tag == "Block")
{
rigidbody.velocity += jumpForce;
}
}
}
Whenever I check the console, the message "OnCollisionStay" is only printed 21 times. Just for more details the GameObject this script is attached to contains a rigidbody that uses gravity, has the x, y, and z rotation axes frozen, and the z position axis forzen as well. The gameObject I'm trying to collide with has a simple box collider attached to a cube with a scale of (5, 1, 5). What am I doing wrong? I am under the impression that OnCollisionStay continuously executes until the player is no longer colliding with anything, then starts executing again on collision?