What do you want to achieve?
I am trying to get my character to point to my cursor
What is the issue?
the character is not pointing to the cursor when an animation plays
What solutions have you tried so far?
I do not know the problem yet but it is either:
a problem with Worldspace or Objectspace
a problem with animations (i suspect the rotation of the torso in the bike animation)
a problem with how I set the Motor6d
this is how i am doing it
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local RightShoulder : Motor6D = Torso:WaitForChild("Right Shoulder")
local Offset = CFrame.new(1,0.5,0) * CFrame.Angles(0,math.rad(90),math.rad(90))
local PlacePart = Instance.new("Part",workspace)
PlacePart.Anchored = true
PlacePart.BrickColor = BrickColor.new("Really red")
PlacePart.Size = Vector3.new(1,1,1)
PlacePart.CanCollide = false
PlacePart.CanQuery = false
local PointPart = Instance.new("Part",workspace)
PointPart.Anchored = true
PointPart.BrickColor = BrickColor.new("Really red")
PointPart.Size = Vector3.new(1, 1,2)
PointPart.Transparency = 0.7
PointPart.CanCollide = false
PointPart.CanQuery = false
while ResetArmsTrack == nil do
task.wait()
end
ResetArmsTrack:Play()
RunService.RenderStepped:Connect(function()
PlacePart.Position = Mouse.Hit.Position
local Direction : Vector3 = CFrame.lookAt(Character["Right Arm"].Position,Mouse.Hit.Position)
PointPart.CFrame = Direction
local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation()
RightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)
end)
I have a reset arms animation that plays to stop other animations changing the position of the arm
idk why I had to do âRightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)â I just did trial and error
I think its because the front of the arm isnât where the hand would be
i highly suspect the animation is causing the problem because it rotates the torso and i am basing the object space of it ( local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation() )
as u can see it get messed up as soon as i get onto the bike
the example in the link did not work so i used adjustweight()
âââlua
local BikeIdle = Instance.new(âAnimationâ)
BikeIdle.AnimationId = ârbxassetid://15027342446â
local BikeIdleTrack : AnimationTrack= Animator:LoadAnimation(BikeIdle)
BikeIdleTrack:AdjustWeight(0)
âââ
but it didnt change anything
i tried setting it to 0.001 too because i hear that 0 doesnt work
ok well ig i wasnât clear enough
anyways, hereâs a little code block to help you understand what i meant
local Part1 = RightShoulder.Part1
local Part0 = RightShoulder.Part0
local C0 = Offset * CFrame.Angles(Y,0,X)
if Part1 and Part0 then
RightShoulder.Enabled = false
Part1.CFrame = Part0.CFrame * C0 * RightShoulder.C1:Inverse()
else
RightShoulder.Enabled = true
end