Hi I have been using Brackeys tutorial on fps and is working on expanding it.
I have been looking at tutorials about picking up guns and such but none is right.
I plan on having a multitude of guns and accessories with a number of items in the weapon list, so having 50 or more items inactive and checking each in a foreach loop doesn’t sound to good when you might be scrolling through them more often.
My idea is to have a simple trigger that when entered parents the weapon to the player.
void OnTriggerEnter(collider player)
I tried using Instantiate and set the parent in that and it didn’t work.
I tried transform.parent = player.gameObject.transform;
transform.setParent
and nothing works. It won’t add anything to the player in the hierarchy.
No tutorials regarding this. I want an object to just become a parent. I deal with the positioning and such later, all I want now is to make the trigger object a child of the player when the player enter it.
The solution was transform.parent = player.gameObject.transform but I had written an if statement that checked if the collider had the Player tag which unfortunately didn’t work which caused it