#How do i choose rotation direction for align orientation

1 messages · Page 1 of 1 (latest)

dreamy crane
#

right now the align orientation just rotates clockwise and counter-clockwise randomly, but i want to specify which direction it goes

#

btw it rotates the char 180

dreamy crane
#

pls explain

#

ive never used align orientation before

pure pulsar
#

well you can use variables and if statements to make a choice Thumbs

dreamy crane
# pure pulsar you then use some math that align orientation wants https://create.roblox.com/do...
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

pure pulsar
dreamy crane
#

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

pure pulsar
#

i think you misunderstood the question

#

what exactly does each line of this code do?

dreamy crane
#

you want me to explain every single line individually e

pure pulsar
#

i didn't ask what it did in general

dreamy crane
#

great

#

first line referencing the alignorientation i added in the char HRP

#

second line sets the CFrame

#

4th detects the hum MoveDirection changing

pure pulsar
#

holup

pure pulsar
#

not what the line does generally

#

it sets the cframe, okay, sets it to what?

dreamy crane
#

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

pure pulsar
#

is it facing the way you want?

dreamy crane
#

2nd image is when align.CFrame = charHRP.CFrame

pure pulsar
#

can you tell me what each parameter you're passing into CFrame.new does?

dreamy crane
#

first param is the position of charhrp

#

second is the goal which is a vector3

pure pulsar
#

did you forget to turn off humanoid.autorotate?

dreamy crane
#

or which way it wants to look

#

no its off

pure pulsar
#

then your math is wrong and/or use of these functions is wrong

dreamy crane
#

nah i think youre misunderstanding my question

pure pulsar
dreamy crane
#

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

pure pulsar
#

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

dreamy crane
#

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

pure pulsar
#

use variables and other control code for that

#

complexity sure but that's sometimes what it takes if you want to specify this

dreamy crane
#

eh idk