Pick up system

I never tried this before, so i want a little help and some hints to how to do this.

I am making a scene in where you wake up in the dark and need to find a light source. The light source will be a torch in a wall or in the ground (this doesn’t matter).

How i make a “pick up system” so when i approach the object and press “E”, the torch disappears and then it appears in the hand of the character? It’s in first person.

It should be a simple script that makes the object disappear on trigger and then reappear on a custom location right?

1 Answer

1

Picking up an object usually requires you to look at it first so I wouldn’t use a Trigger. Raycast is a better to do it.

Press E, shoots Raycast at what the player is looking at, if it’s something the player can obtain like a torch, take that torch in as a child of the player.

Ok tnks :)

+1 also consider Physics.SphereCast if you want to be forgiving about where the player looks, to give some wiggle room, or if you're going to be super forgiving and just need to make sure it's visible you can just check if it's visible in the camera using [renderer].isVisible.