- Home /
Question by
TeeveeSquared · Nov 04, 2013 at 08:23 AM ·
collisionrigidbodyvelocityjump
Jumping from a conveyor belt with added velocity
I'm not sure if its the way my collisions or velocity functions are interacting, but the only thing that happens when I jump from this conveyor belt is a stunted little hop, barely off the ground. If I mash the keyboard, I might get a jump off here and there.
If it's the collisions, how might I set up a workaround to get off the ground?
If it's the velocity changes overwriting each other, how might I write them to get the constant motion that I need without interrupting the jump motion?
Thanks for your support
Excerpt from Character Motor Script
function FixedUpdate(){
if (DownwardG){
rigidbody.AddForce(-gravity*rigidbody.mass*Vector3.up);
}
if (!ZeroGrav){
if (!DownwardG){
// apply constant weight force according to character normal:
rigidbody.AddForce(-gravity*rigidbody.mass*myNormal);
}
}
if (Input.GetButtonDown("Jump")){ // jump pressed:
if (isGrounded){ // no: if grounded, jump up
//rigidbody.velocity += jumpSpeed * myNormal;
rigidbody.velocity = jumpSpeed * myNormal;
// rigidbody.velocity = Vector3(0,0,0);
print("Jump!");
//rigidbody.AddForce((550+gravity*rigidbody.mass)*myNormal);
}
}
Conveyer belt script
var x : float;
var y : float;
var z: float;
//private var JumpFix : boolean = false;
//private var OriginalVelocity : Vector3;
private var MoveIt : boolean = false;
private var ObjectToMove: GameObject;
function FixedUpdate(){
if (MoveIt){
ObjectToMove.rigidbody.velocity = Vector3(x,y,z);
//I thought something like this might help but it didn't, at least in the way I attempted
//collidingObject.rigidbody.velocity = OriginalVelocity + Vector3(x,y,z);
}
}
function OnCollisionStay(collidingObject : Collision)
{
print(x);
print(y);
print(z);
ObjectToMove = collidingObject.gameObject;
MoveIt = true;
}
function OnCollisionExit(collidingObject : Collision){
print("exited");
MoveIt = false;
ObjectToMove.rigidbody.velocity = Vector3(0,0,0);
}
Comment