Hi!
I’m currently experiencing an issue with AlignOrientations.
Let me explain my situation. I have an ability, that makes your character face your cursor when fired.
The problem is…
If I just change the CFrame of the HumanoidRootPart, it works, BUT it teleports my character back a little bit. And I don’t want that.
However, If I use AlignOrientation, it doesn’t work, but there is no Teleportation glitch. I’ve already tried creating a part and setting its cframe to the Attachment0 cframe, and it indeed faces the correct way. So the only possible issue could just be the speed at which the AlignOrientation is rotating at.
How would I make the AlignOrientation instantly face my cursor?
There’s multiple properties that affect how quickly the solver reaches it’s goal: MaxAngularVelocity, MaxTorque, Responsiveness, RigidityEnabled. Mess with those values to see if you can get it to have the desired behavior.
Also, I’m not seeing this behavior in the first video. Am I missing something?
It’s because I didn’t dash and do the ability at the same time. If I did, you would be able to see the “Teleport”. This glitch doesn’t appear with AlignOrientation, but it does not make my character rotate towards my cursor fast enough, which is why I made this post
Well I set the ‘RigidityEnabled’ to true, which should, according to the Documentation, “make the physics react as quickly as possible”.
I actually forgot to provide my code, so let me do so now.
if Action == "Hold" then
HoldAnimation:Play()
Humanoid.WalkSpeed = 0
Humanoid.JumpHeight = 0
-- This is where I create the AlignOrientation, and make it face towards the cursor
local A0 = Instance.new("Attachment", Root)
AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.Parent = Root
AlignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
AlignOrientation.RigidityEnabled = true
AlignOrientation.Attachment0 = A0
AlignOrientation.CFrame = CFrame.new(Root.Position, Vector3.new(MousePosition.X, Root.Position.Y, MousePosition.Z))
end
--[[ SIDE NOTE: It works when I hold the ability for a little bit,
because the AlignOrientation has enough time to make my character rotate.
If I were to just instantly release the key, it wouldn't have enough time and
would cause the issue.
]]
if Action == "Release" then
HoldAnimation:Stop()
local Animation = Animations.Play(Humanoid, 18246627717, 1)
CreateVelocity.MoveHorizontally(Character, Config)
AlignOrientation is the most annoying thing to work with in my opinion. every time i just swap to using a BodyGyro and it works every time. you can try using that. other than that ive had the problem with AlignOrientation never working even with rigidity enabled. i just disable that and set the torque to an insane value and that sometimes works
My bad i miss answered , i think CFrame is what you should use to modify the orientation of the character then AssemblyLinearVelocity to move the character
Is your code running from the server? That would explain the teleporting backwards.
For the align orientation, it will always take a non-zero amount of time to move (i.e. it only updates after a physics update). I would recommend updating your code to work with the target direction instead of instantly using the direction the HRP is facing, since the only way that would work is by directly changing the value.