Hey there,
I’ve made an aiming system with a viewmodel, but now I need one without it. And I have no idea how to and if it’s possible.
This is the viewmodel aiming I did a while back
This is the regular non viewmodel gun that I need the aiming thing work:
I thought of one solution which could be making an aiming animation, but then how’d I pin-point exact position in front of the head.
3 Likes
My first FPS system did not use a viewmodel. It moved the right shoulder C0 to the location in the center of the screen. Later versions manipulated the gun itself (handle weld).
Could I get a simple example of that? I find character joins and C0 confusing.
This is the code in my FPS system that moves the arm.
local rightWorld = cam.CFrame:VectorToWorldSpace(AssignedOffset)
local leftWorldOffset = cam.CFrame:VectorToWorldSpace(LeftTargetOffset)
local leftWorld = cam.CFrame:VectorToWorldSpace(LeftAssignedOffset)
--Right arm
local toolOffset = tool:GetAttribute("RightGripOffset")
if toolOffset then
rightWorld += tool.Handle.CFrame:VectorToWorldSpace(toolOffset)
end
--local offsetWorld = cam.CFrame:VectorToWorldSpace(Vector3.new(-offsetmindist, 0, 0))
local RightArmCFrame = CFrame.lookAt(cam.CFrame.Position + rightWorld, to--[[ + (offsetWorld * to.Magnitude)]], cam.CFrame.UpVector)
--[[lRightArmSpring.s = (tool:GetAttribute("RightArmWeight") or .7) * 60
RightArmSpring.d = (tool:GetAttribute('RightArmSpringDamp') or 1)
RightArmSpring.t = RightArmCFrame.LookVector
RightArmSpring.p = RightArmSpring.p.Unit]]
local RightArmWorldCFrameLerped = CFrame.fromMatrix(RightArmCFrame.Position, --[[RightArmSpring.p]] RightArmCFrame.LookVector:Cross(RightArmCFrame.UpVector), camcf.YVector, --[[-RightArmSpring.p]]camcf.ZVector) * angles:Inverse()
RightArmWorldCFrame = RightArmWorldCFrameLerped
C0 = torso.CFrame:ToObjectSpace(RightArmWorldCFrameLerped) * CFrame.Angles(math.rad(90),0,0)
--dbg.CFrame = cam.CFrame
--C0 = torso.CFrame:ToObjectSpace(cam.CFrame)
--C0 = cam.CFrame:ToObjectSpace(CFrame.lookAt(torso.Position + rightWorld, to))
--Lerp the torso CFrame to the HumanoidRootPart's CFrame to increase arm stability
arm.C0 = C0
The important part is the ToObjectSpace
. Also, if you do this, forget about animations (it won’t work).
4 Likes
Yeah this is a bit confusing to be honest. Don’t even know how to practically try this. And about animations, yeah I need them to work
1 Like
system
(system)
Closed
July 23, 2023, 8:36am
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.