I am trying to set up a bodyPosition so my player moves to the direct left or right of the camera's orientation when a button is pressed. I think I may need some trigonometry, but I'm not fully sure. I don't have the best recollection of my linear algebra classes, so i'm wondering if someone can push me in the right direction (I don't work with math a lot so I honestly don't know what im doing).
What I Currently Have:
the camera's Y rotation (in radians, if i should change it to degrees lemme know)
the distance the player would travel
What I Need:
- the end position
local function yOrientation(obj)
if obj then
local cframe = obj:ToWorldSpace()
local x,y,z = cframe.Angles
return y
else
return nil
end
end
function physics:LinearThrust(forceType,D,P,maxForce,distance,camCFrame)
print("thrusting!")
if forceType == "BodyPosition" then
local initPosition = self.hrp.Position -- returns vector3
local rotation = yOrientation(camCFrame) or yOrientation(self.hrp) -- returns radian relative to world space
local thrust = Instance.new("BodyPosition")
thrust.Parent = self.hrp
thrust.D = D
thrust.MaxForce = Vector3.new(maxForce,maxForce,maxForce)
thrust.P = P
-- with initial position and rotation, you need to find the end position
end
end

2 comments
If I answered your question, please mark it as solved. Glad it works great
sorry, thought I already did