playMaker

Author Topic: how can I change gravity so my NPC can walk on walls?  (Read 15692 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #15 on: January 03, 2014, 07:31:52 AM »
Hi,

 Ok, I have attached a package that will show how to apply gravity to a rigidbody based on the mesh it evolves on.

warning: You mentionned in your pm that you wanted to use navmesh, I don't think navmesh will work with changing gravity, just like built in character controllers assume a constant gravity direction ( for jumping typically).

So, you may have a problem of integration between a changing gravity situation and controlling your character or navmesh.

One way I would consider to get away from this issue is to have your mavmesh invisible and only acting as a dummy position for you to follow and then align vertically to the current terrain normal. That would work I think.


Bye,

 Jean

Ok, thanks for your help :)
I've gone back to basics and just trying to get a cube (as its closest to the object I want) and just moving it in playmode over my terrain.  If I just leave the gravity problem for a moment, how can I just set my cube to rotate to the normal of the terrain?

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #16 on: January 03, 2014, 10:14:00 AM »
Have a look at the attachment, it shows a cube sitting on the terrain. My goal is to move my object from say A to B, adjusting the objects rotation, by getting the normal from the terrain.
I understand I'll have to dummy the navmesh, but for now I just want to position the cube onto that terrain and have it rotating itself so it "hugs" the terrain.
I'll worry about the navmesh problem later. 

fromfame

  • Junior Playmaker
  • **
  • Posts: 78
  • Sloppy PM Veteran
Re: how can I change gravity so my NPC can walk on walls?
« Reply #17 on: January 05, 2014, 10:52:14 PM »
Yep, what Jean said about faking things in general saves a lot of work, once I made a huge clock tower with hundreds cogs that actually moved through physics, it doesn't look good but hey it was real?

I achieved nothing lol I should've just faked it.

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #18 on: January 06, 2014, 07:12:35 AM »
Well at the moment I have the navmesh inside an empty gameobject as the parent, then my character as a child, using the raycast to get the normal.  I have it moving from A to B, but there is no rotation from the normal. What am I missing?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how can I change gravity so my NPC can walk on walls?
« Reply #19 on: January 07, 2014, 04:39:31 AM »
Hi,

 ok, that starts to shape in my mind a bit better, I'll work on a sample, basically with a dummy on the floor moving around and a object following that fummy position but aligning itself to whatever it is grounded too, I think this will the right setup.

and ion this case, it's not anymore a question of apply a different gravity, but more a per NPC ground alignment not using physics at all.

bye,

 Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #20 on: January 07, 2014, 08:11:00 AM »

So if I have my moving object as a rigidbody, and use kinematic, I won't need to apply a constant downward force to keep it stuck on the ground, even if the object is on a wall or ceiling?

Thanks again Jean, I look forward to your example.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how can I change gravity so my NPC can walk on walls?
« Reply #21 on: January 10, 2014, 07:13:40 AM »
Hi,

If your RigidBody is set to Kinematic than forces have no effect, so indeed no need to apply forces at all.

bye,

 Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #22 on: January 10, 2014, 07:41:45 AM »
Hi,

If your RigidBody is set to Kinematic than forces have no effect, so indeed no need to apply forces at all.

bye,

 Jean

Ok thanks for clearing that up :-)
I still can't get my object to adjust it's rotation from the normal.  How's that working sample going?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how can I change gravity so my NPC can walk on walls?
« Reply #23 on: January 10, 2014, 08:05:31 AM »
I should have the time next week, currently, I trying to clear the pending threads and unreplied posts on the forum.

bye,

 Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #24 on: January 15, 2014, 11:55:45 AM »
I should have the time next week, currently, I trying to clear the pending threads and unreplied posts on the forum.

bye,

 Jean

Ok thanks Jean. I thought I may have fixed it by then, but still having trouble. I think I need to use quaternian to get the proper rotation. But I maybe totally off track.

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #25 on: January 22, 2014, 05:03:40 PM »
Still can't do it. Jean let me know when you get time. Thanks

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?
« Reply #26 on: January 28, 2014, 03:20:13 PM »
<bump>

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: how can I change gravity so my NPC can walk on walls?
« Reply #27 on: January 31, 2014, 06:28:32 AM »
Hi,

 Here we go, have a look at this, this should give you all you need.

 basically, The actual controller stays vertical, but attached to it is a special "Orientation" gameobject that will conform to the normal of the floor and your visible character simply has to be a child of that "Orientation" dummy.

bye,

 Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: how can I change gravity so my NPC can walk on walls?[SOLVED]
« Reply #28 on: January 31, 2014, 02:35:52 PM »
Hi,

 Here we go, have a look at this, this should give you all you need.

 basically, The actual controller stays vertical, but attached to it is a special "Orientation" gameobject that will conform to the normal of the floor and your visible character simply has to be a child of that "Orientation" dummy.

bye,

 Jean

Thanks a lot Jean!
I have applied it to my model and it looks like it works.
I had a small problem with the rotation of the model when it was aligning to the ground, but I fixed it by setting the rotation to 270x and 180y.
So before it starts checking the normal, the model is upside down and rotated, but works great as soon as your FSM is active.  So thanks again Jean!

« Last Edit: February 02, 2014, 11:04:16 AM by Splankton »