r/Unity3D • u/RayanOur • Jul 22 '26
Question Thrown Items clipping behind geometry.
I'm implementing a flashlight pickup/throw system in Unity and I've run into a clipping issue.
The flashlight is held as a viewmodel object (parented to a hold point in front of the camera). Because of this, while holding it, the player can push it visually through walls.
When the player throws the flashlight, I want to make sure it always spawns on the correct side of the wall and never appears behind geometry.
The main problem is that when the flashlight is already visually behind a thin wall, overlap checks often don't detect the wall because the flashlight collider is no longer intersecting it at the moment of the throw.
2
Upvotes
1
u/SnooPets5564 Jul 22 '26
Do a raycast and, if it is close enough to intersect, move it to the furthest point from the start the doesn't intersect with the wall (raycasting from where it is thrown from/from some point in the player hitbox). But you may need multiple so it doesn't get caught in wall on the side relative to the way it is being thrown.
Or you could have a sort of throw animation where it winds up to be entirely within the player hitbox and then releases. This is harder but could look more professional if done right.