I want to rotate a part relative to the way a player is looking at it (for example, 45 degrees right). Example:
player looks at part from the front, it rotates like this:
player looks at part from the side, it rotates like this:
I have tried rotating the part but it always seems to rotate the part relative to the global X Y or Z axis.
1 Like
how part should be rotated from front
how part should be rotated from side
1 Like
lV0rd
(Tin)
June 22, 2023, 8:17pm
#3
there’s 2 ways i could think of doing this:
part.CFrame = Camera.CFrame - Camera.CFrame.Position + part.Position
and
part.CFrame = CFrame.LookAt(part.Position, Camera.CFrame.Position)
1 Like
If I understand correctly, wouldn’t these lines make the part look at the player? If so, I do not want the part to look at the player, I want it rotate based on the way a player looks at it.
1 Like
lV0rd
(Tin)
June 22, 2023, 8:24pm
#5
so if i understand correctly you want the part to face the player, not the camera. right?
I’ll make it a bit easier to understand. Say a part is already facing the player (in player’s perspective, the part is lined up). Now I want the part to rotate 45 degrees to the right.
1 Like
Just like this, now I want the part to rotate 45 degrees to the right.
1 Like
lV0rd
(Tin)
June 22, 2023, 8:31pm
#8
something like:
part.CFrame = CFrame.LookAt(part.Position, Character.HumanoidRootPart.CFrame.Position * CFrame.angles(45,0,0))
right?
1 Like
Something like that, but not quite. It still rotates on the global X axis.
1 Like
lV0rd
(Tin)
June 22, 2023, 9:09pm
#10
hey! appologies for the late reply, i got what you wanted here!
local lookVector = (humanoidRootPart.Position - part.Position).Unit
part.CFrame = CFrame.new(part.Position, part.Position + lookVector)
3 Likes
system
(system)
Closed
July 6, 2023, 9:10pm
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.