Hey!
I’m at the moment trying to rotate a part against the opposite direction of the player to create a realistic effect of a player walking through physical-interactable-vegetation. To start with I rotate the part against the player’s position. I then calculate the distance between player and part with magnitude and divide it with the max rotation angle. But it does not live up to what I am trying to achieve.
Here is the coding part:
> game:GetService("RunService").Heartbeat:Connect(function()
local pointXZ = Vector3.new(character.HumanoidRootPart.Position.X,workspace.Look.Position.Y,character.HumanoidRootPart.Position.Z) local arrowCFrame = (workspace.Look.CFrame * CFrame.new(0,0,0)) local x, y, z = workspace.Look.CFrame:ToEulerAnglesXYZ() local mag = (character.HumanoidRootPart.Position-workspace.Look.Position).Magnitude local rotate = CFrame.Angles(math.rad(90/mag),math.rad(90/mag),math.rad(90/mag)) workspace.Look.CFrame = CFrame.new(arrowCFrame.Position, pointXZ) * CFrame.Angles(x,math.rad(90),z) * rotate end)
Any suggestion or help is appreciated!