Adventure Creator 1.77.1
Unity 2021.3.23f
URP-Pipeline
3D Project, with First Person Player Prefab.
I've tried stacking the Cameras by adding one as a child of the MainCamera. Setting it's render type to Overlay and giving the Object a specific Layer, that only gets rendered on this Child Camera.
(Followed this Tutorial, most are alike: How to Fix Weapon Clipping in Unity)
The MainCamera is the active one when playing, so i thought culling the Object there and rendering it on the child camera would work.
But if you set the Layer of the Object to anything other than the default layer, the player can't interact with it anymore, and the Object "vanishes" and doesn't get rendered.
What would be the best way to prevent clipping of objects, when the Player is holding something?
Best regards
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Sounds like you're on the right track with camera culling. To fix the vanishing issue, you can use a script that dynamically alters the layer at runtime - only placing it on your separate layer while the object is held, and back onto the Default layer when dropped.
To do this, you can make use of AC's OnGrabMoveable and OnDropMoveable custom events.
Create a new C# file named DynamicDragLayer and try attaching this to the draggable object:
Thanks Chris, i forgot to add that it also had a Hotspot on it, and when you disable a Hotspot, the Layer gets changed to "Ignore Raycast", but i think i've understood the code a bit better.
I've just hooked into OnHotspotInteract and checked for a tag. I don't know if my solution is janky, but it does work.
I only need to set it once and the object gets put somewhere and is not going to be interacted with again.
If anyone wants to replicate (no guarantees):
If i want to place that object somewhere, by using a hotspot, i clear the parent of the object delete/teleport it and replace it with another one.