playMaker

Author Topic: Slope  (Read 648 times)

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Slope
« on: April 01, 2023, 04:28:34 AM »
Four months I can't solve the problem of rotating a character depending on the angle of slope. I know that raycast is used, but I can't figure out exactly how to do it. Need to calculate a vector between two points, but how? Someone can help solve this problem?

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #1 on: April 01, 2023, 05:35:06 AM »
Finally, I got an angle, but it's the opposite of what I want. How to get negative angle?

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Slope
« Reply #2 on: April 04, 2023, 11:44:25 AM »
1) Use a get position to store the world space position of the character every frame

2) use the "Raycast" action with "From Position" using the variable of the character position in step 1
2a. Set "Direction" to which direction you want it to look (Most likely you'll use Y = -1 so that it draws the raycast out from its feet downwards
2b. Set the space to world, and store the "Store Hit Normal" slot as a variable.

3) Use the action "Quaternion Look Rotation" and fill out the following
"Direction -> Normal variable from step 2b
"Up Vector" -> Position of character
Result -> Store this into a new variable
Every Frame = Checked

4) Set rotation action with "Quaternion" set to the output "result" variable in step 3
Space = World
Every Frame = Checked.

Now the character will always rotate to face the angle of the ground below it.

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #3 on: April 05, 2023, 03:42:34 AM »
It doesn't work. What am I doing wrong? Can you please check?
https://we.tl/t-38WSjO5uZM

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #4 on: April 09, 2023, 05:04:30 PM »
Dear developers, there is no solution to my issue? I've been just trying to make a controller for a four legged character for a long time now. Is it impossible?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Slope
« Reply #5 on: April 10, 2023, 07:25:40 AM »
Hi.
I never tried a 4 legged character, but it should be possible.
Even in normal code I think this is quite complex and dependent on your setup.

if you have issues its better to show in a video than sending files, as most people won't download it.
or have a build version on itch.io for example.

Maybe join discord and ask there.
It has 2000+ member and a 400 members average online.
there are also many tutorials on the server.

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #6 on: April 10, 2023, 02:05:15 PM »
All I need to know is how to keep the character's body parallel to the ground. The controller itself is ready. This is the only problem that I have been unable to solve for several months now.

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #7 on: April 10, 2023, 05:09:31 PM »
Hi.
I never tried a 4 legged character, but it should be possible.
Even in normal code I think this is quite complex and dependent on your setup.

if you have issues its better to show in a video than sending files, as most people won't download it.
or have a build version on itch.io for example.

Maybe join discord and ask there.
It has 2000+ member and a 400 members average online.
there are also many tutorials on the server.

Thanks for the tip. Unfortunately, they didn't help me.

Bender

  • Playmaker Newbie
  • *
  • Posts: 35
Re: Slope
« Reply #8 on: April 19, 2023, 06:27:11 PM »
An experiment N64:
Tried this: https://assetstore.unity.com/packages/tools/animation/ground-fitter-121798, good thing, but doesn't work with Smooth Look At Direction.

I keep trying.