How to correctly reset a falling character

I’m now trying to get going with the Runner game for the competition… due to the nature of the game and the test scene, I created a reset action for the character that takes him back to the start point, for now the level is 5 floor boxes a few units apart with no other large terrain or floor objects below them



this is what is used to reset, which mostly works :

[java]

else if(binding.equals(“reset”)){

character.setPhysicsLocation(new Vector3f(0,25,0));

}

}[/java]



the problem comes if I miss a platform from an attempted jump and press reset the character will be return to the start location but always as onGround = false and will by extension be stuck in !onGround animation state or stuck slightly inside the floor box…but if I wait long enough or play with the movement key everything starts to work again :?



I have “ran” across the platform and reset with no issues, reset in mid air during a jump with no issues… the problem only seem to occur if I reset when the character has missed the platform and is effectively falling out of the “world” I even tried to force onGround to be true with no luck.



I know you guys are not really supposed to help with the competition stuff but, this seems small enough an issue I hope

Make sure that you place the character above the ground (even if its just a micrometer) so that it “falls” and “stops falling” correctly maybe?

1 Like
@normen said:
Make sure that you place the character above the ground (even if its just a micrometer) so that it "falls" and "stops falling" correctly maybe?


yeah I already considered that and set it to about 10 units above where it original starts at load time, even switched it from setPhysicsLocation to warp to account for the possibility that setPhysicsLocation might be producing unwanted collisions or other weirdness, but onGround still doesn't get reported immediately or soon enough after reset, I had the console spit out System outs every update to verify.

There might be forces and the velocity from falling still active. I reset my ball like this:

[java]

ball.setLocalTranslation(ballStartPos);

ball.setLocalRotation(Quaternion.IDENTITY);

ball_phy.setPhysicsLocation(ballStartPos);

ball_phy.setPhysicsRotation(Quaternion.IDENTITY);

ball_phy.setLinearVelocity(Vector3f.ZERO);

ball_phy.setAngularVelocity(Vector3f.ZERO);

ball_phy.clearForces();

[/java]

thanks for your help…but that wasn’t the issue…as it turns out, I completely forget that I had adjusted the floor boxes from being about 5 unit in height to 50 units to more closely look like buildings being looked at from the rooftop, so from the center of each geom the top would be like 25units higher, my character was starting out at 10 unit on the y axis and being “shot up” from inside the geometry to the top of the box, it was happening so quick that I never noticed…essence the physics system would “correct itself” in my favor somehow at start up but not on reset…not completely anyway, so normen was right