Question by
WolfpackPancake · Jul 25, 2016 at 04:12 PM ·
c#bugvector3jumpjumping object
Jump OnCollision() Script not working
basically, I'm trying to make a game that is based off automatically hopping as soon as the ground is hit(the Controller I'm using is the pre-made one that can be imported).In order to do this, I removed the jump function from the controller script and added a script called "Cube" which reads as the following:
using UnityEngine;
using System.Collections;
public class Cube : MonoBehaviour {
void OnCollisionStay (Collision col)
{
if (col.gameObject.name == "Blue") {
Rigidbody rig;
rig= GetComponent<Rigidbody> ();
rig.velocity = new Vector3 (0, 8, 0);
print ("collison detected");
}
}
}
after doing this, I expected a controllable character which jumps as soon as you hit the ground because of the "OnCollisionStay()" trigger. However, instead I get a rapid jump that happens even when I'm in the air which looks like this:
Comment
Your answer
Follow this Question
Related Questions
Player does not jump? 0 Answers
stick to roof of object when jumping 0 Answers
Jumping only once (2D) 1 Answer
My simple jump script is only letting me jump once? 1 Answer