:D
Im trying to make a rigidbody 'Jump' but only when he is on the floor. obviously you cant jump when you are alredy jumping ^.^. thats what exactly do my rigidboy! it "jump" when its alredy "jumping".
Any idea? :P
Thanks!
if(Input.GetButtonDown("Jump"))
{
rigidbody.velocity = Vector3(0,JumpHeight,0);
renderer.material.SetColor ("_Color", Color.red);
}
May be checking if is not touching your "thing" tagged ass floor?...
Send me a msg if it works... i didnt test it, and for bugs or that o:...
Salute.
edit: try with OnTriggerExit and with OnTriggerEnter... dont know what of them may work better...
// new var Jumping
var Jumped = false;
// your code
if(Input.GetButtonDown("Jump") && !Jumped)
{
rigidbody.velocity = Vector3(0,JumpHeight,0);
renderer.material.SetColor ("_Color", Color.red);
Jumped = true;
}
function OnTriggerExit( touching : Collider )
{
if(touching.gameObject.tag == "Floor")
{
Jumped = false;
}
}
Joshua
February 21, 2011, 1:44am
3
function Update() {
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
Much easier and works fine. Assumes you have the Charactercontroller script on your character of course.