How to get viewmodels to not clip thru walls

Hello. This post is explained by the title - how do I set up a viewmodel to not clip thru a wall? I know about ViewportFrames, but I want to keep the shading on my model. I have seen Arsenal Reloaded’s developers get this working, and I know it’s not in a viewport frame because animations are playing on the viewmodel. How would I get the effect that A2’s devs managed?
Thanks!

1 Like

You use RunService.RenderStepped or RunService.Stepped/Heartbeat to update the viewport.

You would need to clone the model and parent it to the viewport camera, setting it’s position and rotation if needed.

I’m pretty sure in Arsenal the gun model is just super small and directly in front of the camera so that even when you’re touching a wall the gun isn’t touching it

Don’t use a viewport frame. You lose the environment’s lighting and they’re low res.

What are you suggesting then

Summary

This text will be hidden

i think to get viewmodels to not clip thru walls apply the position with raycasting

This.

‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

Well, there are 2 Solutions here, ViewportFrames or Model Scale, I feel like Moel Scale is self Explanatory, so I’ll just talk about ViewportFrames

In some games outside of Roblox, The Weapon Rendered Spearately from the Actual Game itself, Which would prevent the Clipping of the Item you’re holding, The closest thing you will get this sort of thing is a ViewportFrame which would allow you to Render a 3D object in a 2D space.

Its not Impossible to have Animations Played on a ViewportFrame as they allow you to do that, if you are trying to Replicate the Exact Movement of the Players Body Parts, you can copy the CFrame of the Current Animation Playing on a Motor6D using a Hidden Property called Transform, then you apply it to another Motor6D.

You can Copy the Light Direction of the World under the Viewports LightDirection, and Apply it to the ViewportFrame, Its actually pretty simple to do.

As @FloofyNezzled said but with a video and code example:

My weapons consist of a lot of meshes so a system like the one you mentioned isn’t going to work (very efficiently at least). Also, my system uses a lot of C-Frame offsets so model scale via properties wouldn’t work. I noticed that in the Arsenal video, the movement of the view model is very smooth, and the view model isn’t low quality as if it were in a viewport frame. I need a way for a heavily C-Frame reliant engine. Thanks.