|
So I'm working on a game that transforms the First Person Controller whenever they come into contact with an object. The Controller is transformed 1 unit up on the y axis. While the controller will transform perfectly if it walking and it hits the object, if the character hits the object while jumping then the transform seems to add to the jumping velocity and launches the controller super high in the air. Has anyone else noticed this and/or know of a solution to it?
(comments are locked)
|
|
The jump with the character controller is performed with a velocity and the function move. When you hit that cube while jumping, the velocity is unchanged, so it keep travelling the distance it's supposed to, plus the +1 unit you gave it. I'm not sure that accuracy (+1 unit) is going well with physic, you might have to choose between them. Thank you for replying, is there a way I can disable the jumping mid-script? So that once it collides with the cube while jumping, the jumping stops and the +1 takes over?
Feb 29 '12 at 05:41 PM
L5D7
CharacterMotor have a SetVelocity function. call SetVelocity(Vector.zero). Be carefull, SnedMessage("OnExternalVelocity") will throw an error if you don't have the function, as well add SendMessageOptions.DontRequireReceiver to it.
Feb 29 '12 at 06:05 PM
Berenger
Thanks for the advice but that didn't quite work. It changes the velocity but the velocity is compiled every update so it doesnt matter what you change it to. I was able to locate where the controller is being launched upwards, it around line 402 in CharacterMotor.js velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime; movement.velocity.y is the reference that is the enormous jump (the value was around 40 at it's highest). To fix it I put a limit on the velocity right after this line so that if the velocity is over 6, then limit it to 6 (6 was the value for an average jump). velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime; if(velocity.y > 6) velocity.y=6; This works and the Controller now jumps and translates together without high-five-ing the moon. Thank you again for your help.
Feb 29 '12 at 09:39 PM
L5D7
(comments are locked)
|
