playMaker

Author Topic: How to stop character from falling over  (Read 2466 times)

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
How to stop character from falling over
« on: August 19, 2016, 01:58:18 PM »
Hey all,
I have a fairly complicated set up that's also causing me a problem I'm not sure how to fix. I have a quadruped set to follow an empty navmesh agent. I'm doing that because I'm using a rigidbody with a box collider on the quadruped so that it tilts when walking up/down hills.
The problem is that sometimes the character with the box collider falls over onto it's side. I can't really use the freeze rotation feature since I really need it to tilt with the terrain.
What do you think might be a good way to keep the character from tipping over?
I've thought about placing empties on each side with raycasting, but that seems overly complicated for this.?

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to stop character from falling over
« Reply #1 on: August 19, 2016, 06:28:11 PM »
Just thought of something; would if be possible to freeze the rotation relative to the characters direction? That could work if there's a way to do so..

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: How to stop character from falling over
« Reply #2 on: August 19, 2016, 07:51:52 PM »
are you using a rigidbody just for the slopes? because you could raycast down and rotate the character relative to the hit normal

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to stop character from falling over
« Reply #3 on: August 19, 2016, 08:07:47 PM »
Yeah. I tried that already and couldn't get it to work right. I also tried casting from the front and back legs and averaging the normal but it still wasn't working.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to stop character from falling over
« Reply #4 on: August 20, 2016, 10:44:23 AM »
Hi,
Maybe you could use a float clamp on the rotation.

everycolorfades

  • Playmaker Newbie
  • *
  • Posts: 20
Re: How to stop character from falling over
« Reply #5 on: August 20, 2016, 09:32:54 PM »
Maybe you could use a float clamp on the rotation.
If the float clamp could wrap the rotation that would work.

I tried rotating with the ground normal again using a quaternion, the problem with that is I can only y rotate a navmesh enabled character.
So currently I have my character continually positioned at the navmesh object, trying to y rotate with the navmesh and x/z rotate with the quaternion. The x/z works if I disable to y rotation, and the y with the x/z disabled, but with both it looks rotated backwards. Inverting the quaternion doesn't solve the problem either.  :o


<EDIT>
Wow, it seems to be working now - the rotate with ground normal stuff is on a parent object and the rotate with navmesh y is on the actual model. Thanks so much terri & djaydino for the posts.
« Last Edit: August 20, 2016, 10:18:43 PM by everycolorfades »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: How to stop character from falling over
« Reply #6 on: August 21, 2016, 09:08:09 AM »
I am Happy you got it to work :)