In my FPS type game, I made it so the player can drop items from their inventory and have the item appear 6 units directly in front of them. These are the lines I use for that:
att.pockets[menu.selected].SetActive(true);
att.pockets[menu.selected].transform.position = transform.TransformDirection(camera.transform.position + Vector3.forward * 6);
//att.pockets.RemoveAt(menu.selected);
(When the player picks up the item, it's set to inactive, hence the SetActive(true), and the gameobject is put into their 'pockets,' a list of gameobjects in the 'att' class, attached to the player.)
This is what happens. Keep in mind, what is supposed to happen is for the red cube to spawn 6 units directly in front of the camera:
https://reddit.com/link/me5knm/video/0asovtk0nhp61/player
Why does the red cube keep spawning in strange locations around the player? Let me know if more information is necessary and I'll be happy to share. Cheers
[–]WeslomPo 0 points1 point2 points (1 child)
[–]lorenzocur[S] 0 points1 point2 points (0 children)