How can is auto rotate to floor angle

How can I make my character rotate to level slope and ramps
I’m using sphere collision but lets say I add a inviable box in the centre to get everything but the ball to rotate and the ball is just for looks ill have everything attached to the box so when I go up a ramp that 45 degrees the box with the weapons attached will rotate too,
I have drawn out and example hopefully its easier to understand that my message.

Take the C++ response on this thread rotation-from-normal and try to translate it in BP.

I’ll give it a shot Thank you

How about this:

302198-rotation.gif

1 Like

That is exactly what I was looking for Thank You!!! One bad thing though the capsule jitters when I look right or look back down any idea’s

Sorry. Since you wrote that it was a 3d top down game, I assumed you wanted this to happen in any direction and not only 1.

I know, I didn’t test it going down :slight_smile:

Will come back soon…

Sounds a bit like your capsule is rotating with the camera, is that right?

On your gif the character tilts up which is great but when he turns around his he still tilted up need him to tilt down same with left and right
best example is Get a cube add a ramp facing different directions Enable surface snapping set surface offset to 85 Click Transition (W) Click on the cube drag the white centre ball up each ramp
I would like to be able to get that kind of rotation but when my character turns around he’s rotated looking up not down

This is an example of what i’m trying to do
going up hill is fine but going Right Left or Down the ramp does what the right side shows

trying to get the left hand side result

Thanks I keep looking into to car template to find out how the car can go vertical and sideways without doing what the right side does but I’m getting nowhere :smiley:

… and five minutes later, I find a much better way:

( you still need to use the rinterp to stop it being ‘buzzy’ when changing surfaces )

2 Likes

Thank you so much, Glad you helped me out I managed with the first upload you did works like a dream had to put a simple branch to set rotation to default if trigger didn’t hit, just if by any chance it didn’t touch, but this one looks nice,
I gave this one a try but it didn’t work your other that your removed worked great

I’m trying to do the same thing, but with a third person character. The suggested blueprint works well, except for the fact that in the third person char blueprint the capsule middle is set to the origin, so the character rotates on it’s middle and not arond the foot (the axis should be, in my opinion, just under the foot, where it touches the ground). This causes two different issues that I’m breaking my head trying to solve (keep in mind I’m a newbie so there’s probably an easy solution that I don’t know / didn’t think of):

First issue: If the character jumps and lands on a slope and keeps still, the foot sinks into the ground a little bit. This happens because the hit happened when the char was upright (falling) and then the rotation was set. Since the character’s axis is in the center and not right under the feet, when it rotates the perpendicular distance from middle of character to ground plane (slope) is a little bit smaller than the distance to the ground in a straight down direction, making the feet sink in the ground a few centimeters.

Second issue: If you stand where there’s a somewhat sharp change in the angle of the ground, the character will become very jittery. The more abrupt the change in the angle, the more violently the char will jitter. This also happens because the axis is in the middle of the character: when it rotates trying to match the angle of the ground just underneath, the ‘down vector’ of the character shifts to the other part of the ground where the angle is different, so it then rotates trying to match this new angle, but this causes it to shift to the previous part of the ground and repeats the same thing in a loop, making the character jitter.

My first idea was to find a way to move the capsule in the character blueprint so the bottom is in the origin, but apparently you don’t have the option to move the capsule. So I don’t know what to do and would appreciate any help or insight.

Hi - yes, it was only a concept, it’s not meant to be the final solution :slight_smile:

As far as the jitteriness goes, rather than doing the correction on tick directly, it would be possible to correct using tick and interp. Or some solution where the correction is only allowed over certain intervals.

As for the capsule, you’ve probably seen the forums littered with questions about that.

I think you have a couple options:

  1. Write your own character in C++

  2. Ditto in blueprint, maybe possible.

I might add, I have no idea how to do either of these…

Anything that has capsule component can be changed to Mesh component and it stops the jitter on corners didn’t have enough time to adjust to the capsule component rotates with the mesh but its probably only 1 or 2 to change back to capsule component from arrow or anything that you choose to get your rotation from

No words kinder in a hurry but just change the CC to Mesh or even arrow to get what you wanting to stop with it been under the feet of the character the CC will try a just to the curve on itself if that make sense…

338070-capture1.png

I just realized I didn’t even thank you in my previous comment, so thank you!

Thank you for your feedback.
Unfortunately this doesn’t solve the problem, because the issue is caused by the fact that the capsule rotates around it’s middle (the axis is in the middle and not in the bottom of the capsule). So rotating the capsule or rotating the pawn doesn’t make any difference, at least not for this purpose.
For good measure I tried copying your blueprint just to check if I was missing something, but it didn’t solve the problems of the feet sinking into the ground when landing on a slope or the jittering when standing on the edge where the angle of the floor changes.

If I could find a way to move the capsule up (along with the other components), so that the bottom of the capsule was at the origin, I think it would solve this problem (potentially creating other problems, but I would like to give it a try anyway). But unfortunately the capsule’s position appears to be locked.

I tried interpolating but it doesn’t completely solve the jittering, just makes it slower. And if I reduce too much the interpolation speed then that creates different problems, like when making turns on a slope the character ‘tilts’ because the correction of the rotation is a little delayed.
I’m a newbie so creating the character code from scratch is beyond my skill and knowledge level right now. I appreciate your help, though.

No worries, sorry I don’t have an answer…