#Rotation when on a slope
21 messages · Page 1 of 1 (latest)
Let this COOK
Rotate it to match the normal vector of the ground
4 years?
4 years of pure confusion
you can fetch the normal of the ground very easily, the normal is the direction away from the surface - so simply get the angle of that, and you know the angle of the surface, and you can rotate your character based on that. you might need to adjust it by 90 degrees, though, since I think 0 rotation is to the right and not up?
check CharacterBody2D for "normal," there are multiple ways to fetch it iirc!
Online API Reference for CharacterBody2D. You can also use the offline documentation by pressing F1 in Godot and searching for a class name.
in your case you probably want to get the last collision and get the normal from that, unless you're adjusting the direction it considers down for purposes of "am I on the floor?"
since getting the floor normal only works when, yknow, on the floor
Not all heros wear capes
Just know you are a goat bro
An honest goat
Okay this is sometimes a little inconsistent at times but it seemed to work for me. https://gist.github.com/sockeye-d/0bf32dd8e54a8e7f45c85130aa7fcd39
Basically what it does is it gets the floor angle, and computes the proper rotation and up direction for the CharacterBody2D. All the "raw" velocities from things like gravity and movement inputs are transformed according to body's current rotation. Any collider seems to work pretty well, but circles and rounded boxes work especially well.
A simple player controller for Godot. For #1248051984779579403 message - rotating_player.gd
I changed the script to use a downward-facing raycast instead of relying solely on the collision information
Maybe do a collision on the lowest point in the circle when the player enters. Take the exact height from the loop and place an anchorpoint at the center of it. Rotate the player using that anchorpoint and when the player is down again simply move forward again.
ILL CHECK THIS OUT TOO
Im gonna try all of these out and see which one is the best one for me
Honestly
You all are the best man