Hello Guest

Author Topic: The problem with the character relating to several Collider  (Read 4124 times)

JunkmanCollector

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Heap up
The problem with the character relating to several Collider
« 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:


Code: [Select]
void HeroJump() {
if (HJump == false) {
HJump = true;
HeroBody.rigidbody.AddForce(new Vector3(0, 28000, 0));

GlobalGameSettings.SharedInstance.HeroAction = "jumpUp";
}
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: The problem with the character relating to several Collider
« Reply #1 on: August 07, 2013, 01:42:47 pm »
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.

JunkmanCollector

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Heap up
Re: The problem with the character relating to several Collider
« Reply #2 on: August 08, 2013, 11:23:34 am »
Thanks a lot! It helped.

JunkmanCollector

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Heap up
Re: The problem with the character relating to several Collider
« Reply #3 on: August 09, 2013, 06:45:36 am »
All was cool. But the Character Controller are solving one problem has added many other, such as:
So I went back to my old script and added only one line before AddForce.
Code: [Select]
HeroBody.transform.position = new Vector3(HeroBody.transform.position.x, HeroBody.transform.position.y + 20, 0);And again it became cool.  ;D

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: The problem with the character relating to several Collider
« Reply #4 on: August 09, 2013, 10:13:53 am »
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.

JunkmanCollector

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Heap up
Re: The problem with the character relating to several Collider
« Reply #5 on: August 12, 2013, 10:04:03 am »
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.