Ah, that’s your problem. The trace always needs to be downward ( relative to the actor’s axis ). When you tilt the actor, that’s what makes the trace angle towards the wall.
EDIT: I think the root of the difference between our two results if that by rotating the pawn before you traced you gave the pawn some pitch, so your pawn’s forward vector now has a non-zero Z component, and the MakeRotFromZX utilizes this?
But not sure how this ultimately helps me for a moving pawn vs a rotating one.
Also of note - if I add a 45degree slope/ramp to ease the transition to the wall, then the pawn will preserve some diagonal motion up the wall, however it is not conserved (ie, im not oriented 45 degrees on the new wall). If I move forward and backward I will not end up in the same position.
Trying to figure out how I could implement some sort of ‘tilting’ into a solution for something like this spider NPC pawn but I can’t see how it would fit in. Say its walking around on a flat floor like this example. How does it know what tilt to attempt as it moves?
So, this is part of the problem of writing a pawn.
You’re locking the pawn to the ground with your tick code.
A basic solution, would be to only use the alignment code when you detect that the angle of the surface normal is not the same as the pawn. That would give you time to angle it.
Hmm so like when the normal of the forward trace differs from the up pawns up vector, then add a local pitch rotation of 45 degrees to the pawn and then retrace from the pawns down vector?
edit: Or maybe the first trace should instead be handled in an overlap event or something?
In the end you probably need to use down vector and forward vector.
If your down v is not at the same angle as the surface normal, you know the player is not aligned with the surface.
When your forward v becomes very short, you know it’s time to raise the front of the actor ( to climb something ).
Stuff like that.
I see, appreciate the feedback. I will toy around with writing some more advanced movement code and see if I can come up with a better approach
This is where the work of making a game is. If you’ve ever played a game where you control a spider, you can tell when you’re playing it. Did they take their time over this or not?
You can tell when the programmers took their time to get it right…
And idea: If you get the cross product of the current aligned surface and the surface to climb to, you’ll end up with an axis that should help you rotate the pawn and maintain movement direction. You could use the dot product between of the pawns up vector and surface normal to climb to get the angle of rotation and lerp.
Awesome, got it more or less working! Thanks a bunch!
For anyone in the future that stumbles upon this, here is the solution to make this work with one trace and the minimal possible logic:
As before we use MakeRotFromZX with the Z being the new surface normal.
We then cross the pawn up vector (normal) and new surface normal to get an axis that is perpendicular to both - this will serve as the axis of rotation for our forward vector. So we RotateVectorAroundAxis on our forward vector and this axis, with the number of degrees equal to the number of degrees between the two normals.
Jesus Christ, thank you SO MUCH folks. I’ve been banging my head on this for about one week I believe. Your help has been invaluable <3