Ingame Object placing - Place objects like Unturned or Ark Survival
I've been looking for a solution googling and I've got nothing. What I'm trying to do is just pick up an object that is somewhere in the scene, put it in the player's inventory and then place it wherever the players want. For example, I get a "poster" and as a player I want to place it on the wall. Or if I get "furniture", place them on the floor. The game is meant to be First Person. Idk if I'm being explicit, but I've tried to explain as best as I can. Thanks!
Answer by Statement · Oct 29, 2015 at 10:41 PM
You can put a physics raycaster on your camera and an event system in the scene to generate OnPointerClick/Down/Up events etc. Then you can create a script that implements one or several of the events you are interested in, for example IPointerClickHander. When you get the OnPointerClick call, you can tell the player to store something in their inventory and disable/destroy the object.
Create a UI for your inventory. When you drag an item out of the inventory, check where the ray is going in OnDrag/OnDragEnded with pointerEvent.pointerCurrentRaycast. Position your object relative to the world position and account for offset so it doesn't get stuck in the wall.
I suggest you look for solutions on how to do either part in isolation if you don't know how, or ask separate questions specific to a single problem. Not several problems.
Your answer
Follow this Question
Related Questions
Animator Position VS Script Vector 3 0 Answers
Has anyone notice this or I am just totally new? 2 Answers
Rearranging Inventory 0 Answers
Inventory script help and how to remove items from inventory 2 Answers
Help with pick up script 0 Answers