How to rotate a part's velocity?

There is probably a simple solution to this but I just need help visualizing.

Lets say there is a ball moving at a velocity of (-15, 0, 0).

How would I make the ball go at a velocity that is 90 degrees to its left or right side?

local amount = +- math.rad(90) -- positive or negative depending on rotate clockwise or anti-clockwise
local Velocity = Vector3.new(-15, 0, 0)
local rotatedVec = CFrame.Angles(0, amount, 0)*Velocity --Rotates Velocity vector around global y-axis

Use CFrame.fromAxisAngle()*Velocity to rotate around a different axis
1 Like

The intuition behind this is in linear algebra. For any arbitrary 3d rotation, you could multiply the velocity vector by the rotation matrix for the angle you want to move it by.

In Roblox there are methods that represent this for you, like what the Solution posted.

3 Likes