How do I rotate a sphere in it's direction of movement?

I have the movement vector, but I am stuck at how to rotate it relative to where its moving

1 Like

Im not sure why you would do that if it does that by itself since its a ball

I’m creating my own, ball movement per say…

So I have the ball moving depending on where it was in contact with something, but now I have to roll it in the direction relative to the contact point

I tried getting the angle of the upvector and the movement vector but I’m not sure if that really works??

I wonder,
Couldn’t you get the Mouse’s LookVector and from where apply the Orientation to move the ball?

1 Like

Dude imma be honest I have no clue how to do that :rofl:

If the X velocity is changing, then the ball would rotate on the Z axis.
If the Z velocity is changing, then the ball would rotate on the X Axis.
Why are the X and Z axis flipped? Well, that’s just how rotation works. When you rotate the X axis, your taking the object and turning it around that imaginary line. If you use the same axis that it’s moving in, it looks like it should be moving to the left or right. So that’s not right.

If you pick any point on the object, and rotate the object around the X axis, the point will move on the Y and Z axis, but not the X axis. And for the Y axis, it will only move on the X and Z. For the Z axis, what do you think will happen?
This is the same behavior as flipping a point around either X or Y axis on a 2D graph. When flipping around the Y axis, the point’s X position changes, but not it’s Y position.

Just something to think about.

I just made this, not sure if the degrees are ordered right:

local ball
game:GetService("RunService").RenderStepped:Connect(function(dt)
	local velo = ball.Velocity -- you can replace with your own movement vector
	ball.CFrame *= CFrame.Angles(math.rad(velo.Z * dt), 0, math.rad(velo.X * dt))
end)
3 Likes

I’m going to try this in a little bit, if it is that simple imma be pissed :joy:

1 Like

Hey I finally tried out your suggestion but it’s not really rolling the way you think it would roll

I changed the ball to a cube so i can more easily see where its rotatin too

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