Calculate the direction of a static mesh?

I’ve been trying to figure this one out for a little while now and I am really struggling. Within the context of a rolling ball controlled by torque, what would be the best way to calculate the direction that the ball is rolling in as a rotation. I’ve been playing around with velocity and all that but I just can’t work it out!!

Any help would be greatly appreciated.

What effect are you trying to achieve? You’ve tried the ‘Rolling’ start template in UE. I feel like it was added recently.

The goal is to know what direction the ball was rolling toward so that I could have something in front or behind it at any time. So I would need to know the direction of a rotation so that the ball could have an artificial front and back

  1. Create a Vector3 variable for the ball called “LastPosition”
  2. On begin play set LastPosition to the ball’s current position
  3. On each tick subtract the ball’s current position by the LastPosition variable
  4. This will give you a length/direction of the ball’s movement
  5. Store the ball’s current position in the LastPosition variable

This should provide you with the forward direction of the ball, provided that it is actually moving.

Vector3 → FVector

I get Unity and UE mixed up sometimes :slight_smile:

Hey, Sorry to be a bother but an FVector doesn’t exist in the Variable type list
(Edit) Also, I don’t know how I can get the rotation from two vectors… Sorry, I’m being a bit slow!

You’re awesome! Thank you for the solution!

Blueprint stores it as something similar (Vector). Perhaps even Vector3.

The position is stored in the static mesh’s transform.