-
What do you want to achieve? Keep it simple and clear!
I am trying to make a sliding feature which instead of instantly turning the velocity towards the desired angle turns you slowly instead. -
What is the issue?
The issue I am facing is that I don’t know how I can use the measured angle (using dot product) to turn towards the desired direction based on a value, since the dot product is always positive/negative no matter if you’re meant to look left or right. -
What solutions have you tried so far?
I tried looking through the devforum and asking ChatGPT for help but it didn’t help much.
Here’s the script I used to test this outside of the character:
local turn_speed = math.pi/4
local prev_dot = Vector3.zero
while true do
local dt = task.wait(0.1)
local dot = script.Parent.Observer.CFrame.LookVector:Dot(script.Parent.Target.CFrame.LookVector)
if dot > -1 then
local start = script.Parent.Observer.CFrame
script.Parent.Observer.CFrame = start*CFrame.Angles(0,math.clamp(math.acos(dot),0,turn_speed*dt),0)
if dot ~= prev_dot then
prev_dot = dot
print(math.sin(dot))
end
end
end