How to make a weapon ADS (Aim Down Sights) without a viewmodel?

I’ve been trying to make a gun system that works how apocalypse rising 1 does, however I’m completely stuck as to how to make the sights work.

What I want is when you right mouse click, the weapons sight (determined by a part) will move to the centre of the screen, and the whole gun will move with it.

The way I have my gun setup is the handle is attatched to a grip part, and the rest of the weapon is attatched to the grip. There is also a weld between the handle and grip.

I know it has something to do with weld C0 and toobjectspace() but the best I’ve been able to do is attach the guns grip to the cameras CFrame. Every time I try to add an offset for the aimpart it glitches out.

I’ve looked all over the devforum and couldn’t find anything that worked. I found a few similar topics but they either weren’t solved or weren’t explained in a way I was able to understand.

How should I go about implementing this? Any advice would be helpful as I’ve hit a dead end with my project because of this.

This is the basic handle attaching to camera script I mentioned, its not aligned with the sight at all but is all I can provide for code. I’m also using a while loop temporarily for debugging.

while task.wait(0.05) do
	local cf = camera.CFrame
	local Difference = handle.CFrame:ToObjectSpace(cf)
	handle.grip.C0 = Difference
end
2 Likes

Then you use the local LocalAimCFrame = Handle.CFrame:ToObjectSpace(aimPartCFrame) and place the handle like: Camera.CFrame:ToWorldSpace(-LocalAimCFrame)
(This is a pseudo code that resembles what I use for aiming)

Sadly i dont have an answer but i also have this question so someone please help.

2 Likes

not sure if I understood properly, I tried adding what you said and it didn’t work.

try this one

local cf = CFrameHere 
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable workspace.CurrentCamera.CFrame = cf

here an explanation, first we get the object cframe of the aim part(relative to the weapon’s primary part) which we can call it AimOffset, then we move the weapon to the camera.CFrame * CFrame.new(-AimOffset.Position). I hope this gives a better understanding

I’m not trying to move the CFrame of the camera, I’m trying to get the weapons sight to be in the middle of the screen when you aim.

I’m still not able to get this to work. Whenever I try setting the weld C0 to the offset between the handle and aimpart, the gun just starts flinging around in random locations.

My issue seems to be something with the offset, as the camera CFrame seems to be working fine.

It might require some adjustments since you are using moto6D, I am unable to help since I’ve just started to use it a bit recently and I still know nothing about it

I’ve been using a weld, and yeah I’m new to this aswell.

Appreciate the help anyway though!

I’m pretty sure that is how tons of games do it

I tried attaching the camera to the aim part anyway, but this just causes the camera to rapidly spin around.

Got something to work!

Not sure if this would work for everyone since my gun is rigged in a specific way, but here’s the code:

adsruntime = runservice.RenderStepped:Connect(function()
	local cf = camera.CFrame
	local Difference = handle.CFrame:ToObjectSpace(cf) --getting the dif between the handle and camera, this is because the weld is contained in handle, even if the handle isnt moving.
	handle.grip.C0 = handle.grip.C0:Lerp(Difference * aim.CFrame:ToObjectSpace(grip.CFrame) * CFrame.new(0,0, -2), zoomtime) -- updating the weld C0, and offsetting the position by the difference between the grip and aim part, then adding a manual extra cframe to put the gun fowards more.
end)

Note that this does not animate the arms.

5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.