I need to make the turn from going up, then going straight, up or down look good and smooth, similar to video 1, but I need to do it to my game, video 2
Video 1
Video 2
Video 1 looks fine, but with mine, it just kind of floats in the air a bit. I’m not sure if I need to do a bezier curve or not.
code
local function UpHillTurn(EnemyData, Position, DeltaTime, Node)
local X, Y, Z = EnemyData.CFrame:ToOrientation()
EnemyData.UpHillDeltaTime += DeltaTime
if EnemyData.UpHillDeltaTime >= (3 / EnemyData.Speed) then
EnemyData.UpHillDeltaTime = 0
EnemyData.UpHillStatus = 0
return CFrame.fromOrientation(X, Y, Z)
else
EnemyData.UpHillStatus = 1 - EnemyData.UpHillDeltaTime / (3 / EnemyData.Speed)
return CFrame.fromOrientation(CFrame.new(GetNode(Node - 1, EnemyData.Path).Position, GetNode(Node, EnemyData.Path).Position):ToOrientation() * EnemyData.UpHillStatus, Y, Z)
end
end
It all works fine, just not sure whether I should do a bezier curve or edit it?
So if I’m correct, and you want to tween the orientation…
You can save the Y and Z values as a variable, create a NumberValue for the X, and then tween that NumberValue to your target X, and then create a GetPropertyChangedSignal connection to to adjust the full orientation of the object whenever the X value changes.
local NumberValue = instance.new("NumberValue")
local OriginalY = Object.Orientation.Y
local OriginalZ = Object.Orientation.Z
NumberValue.Value = OriginalX -- Make this whatever the original X orientation is.
TweenService:Create(NumberValue, TweenInfo, {Value = TargetX}):Play()
NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
ObjectThing.Orientation = vector3.new(NumberValue.Value, OriginalY, OriginalZ)
end)
You can save the values in a table for more consistency.
local NumberValue = instance.new("NumberValue")
local OriginalYZ = {Object.Orientation.Y,Object.Orientation.Z}
NumberValue.Value = OriginalX -- Make this whatever the original X orientation is.
TweenService:Create(NumberValue, TweenInfo, {Value = TargetX}):Play()
NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
ObjectThing.Orientation = vector3.new(NumberValue.Value, OriginalYZ[1], OriginalYZ[2])
end)