Because you cannot tween a viewmodel can someone explain how to make a smooth aim transitions I have been trying to do this for over a month.
this completely depends on how you’re doing this, and how your game is set up. But you can tween viewmodels. How are you viewmodels set up?
It’s a simple viewmodel positioning code to position it at the camera position.
if aim == false then
-- normal code
else
-- aiming
end
Have a CFrame offset for aiming and not aiming, and lerp between the CFrame offsets when you aim down sights
If you have a module with your current viewmodel CFrames you can call them in your script and :Lerp() them under a RunService logic argument, you had a basic idea of it alr
I understand you can lerp but lerping doesn’t have much information and I still struggle getting it to work.
How i do it with my gun systems is something like this
local Viewmodel -- make this = to the viewmodel in the workspace
local Alpha = game.ReplicatedStorage.AimAlpha -- make a number value in replicated storage or something
local Tweenservice = game:GetService("TweenService")
function aim_in()
local AimTween = Tweenservice:Create(Alphal, tweeninfo.new(0.5,enum.EasingStyle.Sine),{Value = 1})
end
function aim_in()
local AimTween = Tweenservice:Create(Alphal, tweeninfo.new(0.5,enum.EasingStyle.Sine),{Value = 0})
end
game:GetService("RunService").RenderStepped:Connect(function(dt)
ViewModel.HumanoidRootPart.CFrame = game.Workspace.CurrentCamera.CFrame
-- Viewmodel.HumanoidRootPart or Viewmodel.Camera, really whatever part is where the camera should be should have its cframe set to the camera's cframe.
ViewModel.GunModel.AimPart.CFrame:Lerp(game.Workspace.CurrentCamera.CFrame,Alpha.Value) -- change the hierarchy here to wherever your "aimpart" is at.
end)
Since the way lerp works is using a number called alpha, which is from 0-1, 0 being its most incomplete state, while 1 is its finished state.
so tweening the number “Alpha” will smoothly set the cframe of the viewmodels aimpart (part where the camera will go when aiming in)
is there a way to accurately set alpha to the cframe of the aimpart?
Could you elaborate on what you mean here? You can put any number from 0 to 1 this includes decimals
Nevermind read the code wrong.
im confused what should I put for tween info and alphal?
also you cannot make 2 functions named the same thing.
Sorry second function should be called aim out, but you get what i mean bund thoee functions respectively to your aim inputs
Alpha should be an actual number value object in replicated storage, for tween info you should put a number (representing how long the tween will take)
I also forgot to make the tweens play so just call the tween followed with :Play()
If you don’t wanna spend time or is generally busy with other stuff you can use FE GUN KIT it comes with a viewmodel function and is very customizable. However it does have some issues, mainly being that gun sounds only play to the shooter and not for others (they don’t replicate).
If i recall it does have some default animations you can use. (you have to reupload them)
? I have been searching for months and you think im not spending time???
Alpha is because you didnt define the value and just rewrite tweeninfo.new() sometimes it messes itself uo when its pasted
WHen I called the function it printed this