0 votes

Hello, I'd want to start by saying that I am pretty new to godot as well as scripting in general so hopefully you'll bear with me...

I am trying to make a 3D sonic fan game in Godot and I'm currently trying to figure out how to have a Kinematic Body handle slopes. The idea is to make it's rotation match whatever surface it is standing on.

2D Example1
2D Example2

I've done my fair share of research on how it works in 2D thanks to the Sonic Physics Guide, as well as on linear algebra, dot and cross products, and quaternions. My problem now is simply translating all of this into a 3D Godot project.

I have a Raycast pointing down relative to the player and I have this script attached to it:

extends RayCast

func physicsprocess(delta):

#Adjust the normal using the collision point
var RelativeNormal = \
get_node("..").transform.origin + self.get_collision_normal();
#Use the godot look_at function to rotate the object
get_node("..").look_at(RelativeNormal, Vector3.UP)

There are some problems, though...

First of all, it isn't rotated correctly. It's on it's back and I think it's tilted a little.

Secondly, after thinking it through, I realized that even if I get it to align to the ground I will also need to rotate the character based on player movement inputs and where the camera is looking. I've seen many tutorials on that, but putting that together with slope physics adds another layer to the issue.

I have asked questions similar to this at r/godot and on the discord server and I've gotten some good advice. I find that the more I ask, although I'm not getting one full solution (for obvious reasons), those that have responded have given me more and more pieces of good and useful advice. That being said, I welcome any input and thoughts on the matter. Thank you! =)

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.