playMaker

Author Topic: Make GameObject always parallel to Ground [SOLVED]  (Read 2759 times)

Livesey

  • Playmaker Newbie
  • *
  • Posts: 2
Make GameObject always parallel to Ground [SOLVED]
« on: April 24, 2018, 10:25:21 AM »
Hi! I searched a lot and still wonder how to solve one simple for first look problem.
 
I have a generic character SPIDER with 4 legs. It controlled by Nav Mesh Agent. I need some how to keep his body always parallel to ground. For example, when spider walks on letters or rocks I need his body to rotate respectively to ground normal.

The problem is that Nav Mesh Agent locks all rotations. And if I create null under spider Nav Mesh controller and put his bones and model in this null, it looks like the only problem is to always point Y direction to normal vector from the ground. I tried different Look At snippets in PlayMaker and always got the same issue: 1. LookAt locks all rotations. 2. It points toward vector Z.

I need somehow to LookAt using Y vector and to keep X and Z vectors free to rotate.

Any ideas or help! Carma +100500 bear +2 =)
 
« Last Edit: April 25, 2018, 03:26:58 AM by Livesey »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Make GameObject always parallel to Ground
« Reply #1 on: April 24, 2018, 12:58:28 PM »
Hi.
I am not sure for navmesh, but i always have my character in an empty parent or a invisible cube and sometimes a parent in a parent event
and i use that parent for the movement

So Navmesh would move (control) the parent and you can still rotate the child object.

Livesey

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Make GameObject always parallel to Ground
« Reply #2 on: April 25, 2018, 03:24:06 AM »
Hi! Thanks for answer, but I found a solution worked for me =)

I used the Playmaker function “Quaternion Look Rotation” as a main solution for rotating character. I attached that to null object inside Main object with NavMesh Agent. In addition, that null contains bones and model itself.

“Quaternion Look Rotation” needs to directions for working: “Up Vector” and “Direction” Vector.

I calculate Up Vector using Raycast from center of character and getting Normal Vector from the ground. A attached one more Null with “Smooth Look At Direction” to get smooth Up Vector from Hit Normal.

Then I created two Reycasts – from character center and with offset to forward vector. I got two hit points and a Direction Vector between them. It helps to detect ground curve smoothly.

So after getting that vectors “Quaternion Look Rotation” start to work like magic. =)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Make GameObject always parallel to Ground [SOLVED]
« Reply #3 on: April 25, 2018, 01:52:46 PM »
Hi.

I am happy you got it to work :)

And thanks for sharing your solution :D

Bender

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Make GameObject always parallel to Ground
« Reply #4 on: April 01, 2023, 10:53:48 AM »
Here's what I need, but the instructions are unclear or too complicated. Can someone explain easier?

Hi! Thanks for answer, but I found a solution worked for me =)

I used the Playmaker function “Quaternion Look Rotation” as a main solution for rotating character. I attached that to null object inside Main object with NavMesh Agent. In addition, that null contains bones and model itself.

“Quaternion Look Rotation” needs to directions for working: “Up Vector” and “Direction” Vector.

I calculate Up Vector using Raycast from center of character and getting Normal Vector from the ground. A attached one more Null with “Smooth Look At Direction” to get smooth Up Vector from Hit Normal.

Then I created two Reycasts – from character center and with offset to forward vector. I got two hit points and a Direction Vector between them. It helps to detect ground curve smoothly.

So after getting that vectors “Quaternion Look Rotation” start to work like magic. =)

Bender

  • Playmaker Newbie
  • *
  • Posts: 34
Re: Make GameObject always parallel to Ground
« Reply #5 on: April 01, 2023, 11:21:36 AM »
Then I created two Reycasts – from character center and with offset to forward vector. I got two hit points and a Direction Vector between them. It helps to detect ground curve smoothly.
How did he get the Direction Vector???