How to do lerp between two normal vectors?

Hello,
i have a small car where i want to change the pitch based on the ground angle.
I shoot a raycast downwards and get the ground normal and then do a lerp between my cars normal and the ground normal to get a smooth transition when going uphill/downhill. I don’t quite understand wich Alpha i should use here so i just use the seconds.

Atleast thats the idea, i couldn’t get it to work properly so here is the BP:

Another problem that i have is, that the car doesn’t change direction when moving up the slope and then down. It just stays in one angle.

THX

1 Like

You wouldn’t use a lerp there, it would be a vinterp ( on tick, presumably you’re already doing the raytrace on tick? )

Thx yeah that seems like what i need. I am doing the raycast on tick, but if i plug the cars normal into the “Current” and the ground normal into the “Target”, shouldn’t i get a smooth transition in yaw? It doesn’t seen to work that way when i try it. I would have to translate the normal value to a pitch value, no?
I am currently recreating this for reference:
https://www.youtube.com/watch?v=Ki-tWT50cEQ&ab_channel=MixandJam (1:25 to 1:35)

Yes, you have the right idea.

To make the normal useful, I think you have to align the up vector with it, because that’s the corresponding vector ( well, * -1 )

But when you do that, the system will want to align the other two directional vectors.

I think you can get around that problem with a ‘get rot from …’ node. You can give priority to the yaw you currently have, for instance

image

What I’m saying is, you can take a vector from the normal, and one from your current orientation like this.

2 Likes

Wow that actually worked perfectly. I don’t quite understand it but thank you very much.

1 Like

You could just say GetRotFromZ, but then your car would be spinning all over the place, because there’s no taking account of it’s forward vector.

So this node with the two inputs lets you get the orientation from the normal, but also specify a direction you want to maintain :slight_smile:

Ok i think i get it a bit. Thx so much!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.