#How do i choose rotation direction for align orientation
1 messages · Page 1 of 1 (latest)
well you can use variables and if statements to make a choice 
you then use some math that align orientation wants https://create.roblox.com/docs/reference/engine/classes/AlignOrientation and there you go 
local align : AlignOrientation = charHRP:WaitForChild("RootAttachment"):WaitForChild("AlignOrientation")
align.CFrame = CFrame.new(charHRP.CFrame.p, Vector3.new(charHRP.CFrame.p.X - 2, charHRP.CFrame.p.Y, charHRP.CFrame.p.Z))
charHum:GetPropertyChangedSignal('MoveDirection'):Connect(function()
if charHum.MoveDirection.X > .5 then
align.CFrame = CFrame.new(charHRP.CFrame.p, Vector3.new(charHRP.CFrame.p.X + 2, charHRP.CFrame.p.Y, charHRP.CFrame.p.Z - 0.01))
elseif charHum.MoveDirection.X < -.5 then
align.CFrame = CFrame.new(charHRP.CFrame.p, Vector3.new(charHRP.CFrame.p.X - 2, charHRP.CFrame.p.Y, charHRP.CFrame.p.Z - 0.01))
end
end)
ts is pretty much all i would come up with
but idont like how it makes the char a little tilted but i dont see any other way
can you explain exactly what each line of this code is doing
yeah
first If is when the plr goes Left and elseif is Right
ts is a 2.5d game btw so its on the side
you want me to explain every single line individually e
i didn't ask what it did in general
great
first line referencing the alignorientation i added in the char HRP
second line sets the CFrame
4th detects the hum MoveDirection changing
holup
i asked, exactly what the line does
not what the line does generally
it sets the cframe, okay, sets it to what?
2nd line sets the cframe to the character facing in the Right direction
bc if i just do charHRP cframe it js changes when you spawn in
im making sure its facing the way i want
is it facing the way you want?
can you tell me what each parameter you're passing into CFrame.new does?
did you forget to turn off humanoid.autorotate?
then your math is wrong and/or use of these functions is wrong
nah i think youre misunderstanding my question
double check this is true, triple check the goal is correct
align.CFrame = CFrame.new(charHRP.CFrame.p, Vector3.new(charHRP.CFrame.p.X - 2, charHRP.CFrame.p.Y, charHRP.CFrame.p.Z))
this flips it but without adding the -0.01 on Z it just randomly rotates clockwise or counter clockwise
i have to add it so the character always flips facing the camera
and i cant think of any otherway to do ts
probably just have to control the motion deliberately
be more specific with it
like align facing the camera and then when it approaches align to facing direction
probably some cframe:lerp functions for that
angle math
etc
addition, subtraction
nah i tried lerping but that would be too complicated bc itll stop mid rotation if i stop input if i just lerp it in the propertychangedsignal connection
use variables and other control code for that
complexity sure but that's sometimes what it takes if you want to specify this
eh idk