Rotate Vector 90 degrees

I cannot find a thread describing how to do this simply. I’ve read a lot, every post I can find, but nothing one to one. I’ve explored how to do it for the last three days and I’m not any closer.

I have a rolling ball game. I’m grabbing the linear velocity of the ball to find its forward direction vector. I then am taking that vector and setting it some distance in front of the ball (temporarily using a cube as representation). At the end of that vector / cube’s location, I then want to take that forward vector and rotate it 90 degrees so that its always pointing “up” in relation to the forward vector (which is actually the linear velocity) of the ball. Any and every way I’ve tried to rotate that vector has been a disaster. Either it is point up on the Z axis but doesn’t adjust and remains static when the ball goes up on different surfaces or it shoots off wildly in all sorts of random directions.

I’ve been reading more about mathematical vectors than I think I ever did in school and I’m no where closer. I thought the cross product node would be my savior (below blueprint), but no effect. I’ve tried simply RotateVector, RotateVectorOnAxis, etc. Its very possible I didn’t use them right I admit, and I’m kind of hoping some has an answer for me.

alt text


Going crazy.

I’m pretty sure this is what you’re looking for (connect your linear velocity to RotationFromXVector instead of my GetForwardVector):

Thank you for the response!

I think you’re answer was pretty close. When I print the value of the End Vector for my Draw Debug line they look like appropriate values, but the effect of the Draw Debug line is still all over the place. I tried a few different rotators as well and didn’t get much effect.

I just had a thought and realized its probably because the end vector for the Draw Line debug is a position in space and not a direction, which I’m supplying. Line tracers (which will eventually replace my Draw Debug line node) also work from positions and not directions. Guessing I need to figure that out now.

Thank you for your help, if you have suggestions for that as well let me know… but now I have another angle to attack.

DrawDebugLine takes a start and a end point you can use ActorLocation for start point and ActorLocation + ComputedUpVector for end point

You’re so right, I did that for an earlier process but forgot for this instance. (just woke up and saw your comment on my phone so I still little groggy :slight_smile:

That works, well almost 99% there. I just need to figure out how to prevent it from inverting when it does. Investigating…

Thank you much! You’re the best.

You’re welcome, you can accept my answer by clicking the chekmark so i’ll earn a small karma :stuck_out_tongue:

Ah I was looking for the resolve button. You’ve helped me again :slight_smile:

Good news, is that I think with what my plans were for that trace… it doesn’t matter that the up vector gets inverted temporarily on a curve like that because I don’t be using the trace on curves (only flat sections). Sooooooooo even that it still bothers me I think I’m all done! You da best.