So, my question is this: What’s the best way to smoothly transition a Vector3 value, into another Vector3 value on an infinite loop? (Another way to describe it might be “Matching the one Vector3 to another, with a delay”?)
The way I’ve tried is with a loop of tweening, which isn’t super performance friendly, and just seems like a not so great way to do it.
Here’s an updated example:
local Camera =workspace.CurrentCamera
local Render_Stepped =game:GetService("RunService").RenderStepped
local Offset =Vector3.new(0,0,-20)--This value will not change, it's only purpose is to stiffen the delayed movement by moving the end point back
local Tween_Service =game:GetService("TweenService")
local tweenInfo =TweenInfo.new(
-1, --RepeatCount (when less than zero the tween will loop indefinitely)
false, --Reverses (tween will reverse once reaching it's goal)
local Dynamic_MousePose =script.D_MPoint--A Vector3 Value
local PL_Head =script.Parent.Parent.character.Torso--Not actually using the head
script.Parent:SetPrimaryPartCFrame(CFrame.new(PL_Head.CFrame.Position+Vector3.new(0,1.5,0),Dynamic_MousePose.Value)*script.Parent.V_Offset.Value*script.Parent.V_Rotation.Value)--"V_Offset" (CFrame.new) and "V_Rotation"(CFrame.Angles) will both change in-game.
The desired outcome, is the Vector3 (position in this case) transitioning into another Vector3 as smoothly as possible, updating and moving properly when the goal Vector3 changes.
Although this code does do that, I’m sure there must be a better way, I just have no idea what that is…
Any help or tips you can share would be greatly appreciated. Thanks.
local function Lerp(A, B, Alpha)
local Dynamic_MousePose = workspace.D_MPart
Dynamic_MousePose.Position = Lerp(Dynamic_MousePose.Position, workspace.TestPoint.Position, DT*10)
I’m trying to achieve the weigh movement effect common in most FPS.
Where the weapon your holding moves slightly slower then your camera as you look around.
Using a point that updates to the center of the screen, with a delay, was the best way I could think of to achieve this.
(The gun points to this point moving around after the camera)