playMaker

Author Topic: Alligning Character Angle To Floor  (Read 3537 times)

Xinus22

  • Playmaker Newbie
  • *
  • Posts: 1
Alligning Character Angle To Floor
« on: February 14, 2017, 01:47:06 PM »
t
« Last Edit: June 10, 2021, 09:40:22 PM by Xinus22 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #1 on: February 15, 2017, 02:14:40 AM »
Hi,

what kind of character are you using, it's important because for example a third person character component will not allow you do to so.

 Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #2 on: February 23, 2017, 03:37:58 AM »
Hi,

 ok, so I modified it, and yes, the jump will need to be done differently with likely proper raycasting ot something as is, the mods to follow ground corrupts the jumping and grounding behavior.

 I modified the "Movement" Fsm:

- I get the normal of a raycast hit going down in the world ( this will need to be checking for wether it hits a ground object or not, use layers or more complex fsm to do this)

- then I use the horyzontal axis within a crossProduct to get the up AND forward direction in one go (quite happy with this trick actually, else it's a nightmare to combine rotation of character and ground normal :) )

and that's it really. I keep the velocity as is without reflecting the angle of the character, I don't think you'll have ground at very high angles anyway, else you would then need to express velocity in local coordinate of your character

I have attached a modified scene taken from the tut you mentionned.

Let me know how it goes :)

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #3 on: January 19, 2018, 01:16:45 AM »
Hi,

 you'll need to fiddle a bit more with it, what do you want, that it follows angle or that it stays vertical?

 Bye,

 Jean

Stuard

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Alligning Character Angle To Floor
« Reply #4 on: April 01, 2018, 01:50:30 PM »
hey Guys,
i hop its not off Topic but i want to ask - ive created a non physical player controller for my game and get the normal of the terrain via raycast to align my character to the ground - quaternion up via [...] from rotation (0,1,0). It works perfectly when the player faces forward in world direction but i cant get my head around how to make it possible to rotate. Via the Rotate action and some fiddeling i get it to work but well the normal rotation doesnt work when the controller faces the 180° mark.

Greetings,
Stu

looks like in the attachment then - how can i get my character to rotate and keep the grounding corrrect?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #5 on: April 03, 2018, 06:42:30 AM »
Hi,

 did you try the package from earlier in that thread?

 Bye,

 Jean

Stuard

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Alligning Character Angle To Floor
« Reply #6 on: April 03, 2018, 08:07:19 AM »
Thanks for the reply Jean :),

I tried to install it but it won’t extract into my unity folder :/
I’m using unity 2017.3.1

-i correct myself, didnt get that it is a .scene  ::) Im going to look in this now  ;D

Greetings
Stu
« Last Edit: April 03, 2018, 12:10:18 PM by Stuard »

Stuard

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Alligning Character Angle To Floor
« Reply #7 on: April 03, 2018, 05:19:24 PM »
Hi :)

Sorry, but i dont realy get the setup in the previously posted scene (or it does not work correctly on my side (I don’t get ground allignment)?)  :-\
My FSM tree looks as follows and i dont realy now where i can add/multiply the forward direction (if i use a parent object).

Greetings,
Stu
« Last Edit: April 04, 2018, 02:53:30 AM by Stuard »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #8 on: April 04, 2018, 03:03:30 AM »
Hi,

 I see, you need to start again, with the minimal stuff. Make it align to the ground, once that works, make it rotate around itself based on inputs.

 Also, have you tried to separate your logic into several Fsms, this might help and have less crowded states with dozens of actions, it's never a good thing to have so many actions.

I would move and rotate on regular update and then another fsm would align to floor on late update.

Bye,

 Jean

Stuard

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Alligning Character Angle To Floor
« Reply #9 on: April 04, 2018, 03:48:02 AM »
Hello :),

Allright i have 3 FSM's so far, one for the animation controll, one to apply Rotation, Translation and the calculated ground alignment :). The last state is to grap the Ground angle and get a Quaternion which i calculate with the help of another post you replied to.

If i would reduce my game to a 2D sidescroller, the ground alignment would work perfectly.

The problem i would think about is, that i hard set the calculated ground alignment with set rotation (when i leave the smooth rotate to function aside) and the rotate function stands in conflict whith that so it wont rotate because i set the rotation also every frame :) - When i seperate (i tried that 2) The ground alignment to one object and apply the Translation and Rotation to a Parent it ends in the missalignment of my first post around the 180° mark

My first version also had just one raycast to get the normal without the averaging stuff but there where the same problem - It also makes no difference casting in world or self space :)

- Sperating final ground alignment and the Rotate action ends in a Front facing Jittering :/

https://drive.google.com/open?id=1-1MKEptck3nH8cc7wDktdWOZNoJP7UFB

Greetings,
Stu

Stuard

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Alligning Character Angle To Floor
« Reply #10 on: April 04, 2018, 12:07:40 PM »
Allright, i got it

i hope the picture below explains it. For short and a realy easy way; i align a parent to the ground wile rotation the child inside in self space. Then get the forward direction and translate the parent times the input speed via the translate action :)

Greetings,
Stu
« Last Edit: April 04, 2018, 12:42:32 PM by Stuard »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Alligning Character Angle To Floor
« Reply #11 on: April 05, 2018, 02:46:22 AM »
Hi,

 Good, I am glad you sorted it out!

 Bye,

 Jean