2D Toolkit Forum
2D Toolkit => Support => Topic started by: JunkmanCollector on August 07, 2013, 01:21:28 pm
-
Hello.
I have the following problem. There is a character, the character moves through the level. Make jumps. The character have Rigidbody and Box Collider. If its Collider contact with only one another Collider, then all is well, but if in contact with two or more (for example, a character stands on two boxes at the same time), then the force of the jump is reduced two times approximately. Why is this happening?
Jump code:
void HeroJump() {
if (HJump == false) {
HJump = true;
HeroBody.rigidbody.AddForce(new Vector3(0, 28000, 0));
GlobalGameSettings.SharedInstance.HeroAction = "jumpUp";
}
}
-
Thats expected behaviour with the Unity physics engine + rigidbody addforce. I reproduced this using 3 boxes when I last investigated it. If I remember correctly, the character controller isn't affected by this, so that might be a better choice here.
-
Thanks a lot! It helped.
-
All was cool. But the Character Controller are solving one problem has added many other, such as:
- Character are falling through dynamic objects, if the ones at least slightly move.
- To move dynamic objects have to write a script on the impulse transfer. Use of official functions OnControllerColliderHit (http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html (http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.OnControllerColliderHit.html)) can not solve the problem. Sometimes it works fine, but sometimes the dynamic objects are pushed deep into the static.
- Other minor nuisance, for which it is necessary scripted.
So I went back to my old script and added only one line before AddForce.
HeroBody.transform.position = new Vector3(HeroBody.transform.position.x, HeroBody.transform.position.y + 20, 0);And again it became cool. ;D
-
Nice hack.
FWIW, there are nice solutions to character controller with elevators / moving platforms -
http://answers.unity3d.com/questions/8207/charactercontroller-falls-through-or-slips-off-mov.html
Or you could get the 2D Character controller from JNA Mobile - the sample supports moving platforms, so I'm guessing elevators should just work?
http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,2185.0.html
Might be an idea to get in touch with the author to check. The latest version has a 2D Toolkit sample built in.
-
Thanks for the links. ;) I started to think about the lifts and platforms, but has not yet reached it. So far, only jumps. There are still many problems that I have to solve.