- Home /
Pick something up with name - ontrigger
I'm making something and want to pick up something. When you pick it up you can see it in the inventory. That part works but it doesn't detect it.
(This script is on the player) This is what I have now, does anybody know why it doesn't work? - yes the objects have a trigger
private void OnTriggerEnter(Collider other)
{
if ((other.gameObject.name == "NAME1") && (Input.GetButtonUp("Fire2")))
{
IMAGE1.GetComponent<Image>().sprite = IMAGE2;
}
if you put the script on any game object with a trigger it should work
Answer by jellygamingplayz · Jan 07, 2019 at 08:40 PM
try putting the script on the object with the trigger instead
How can I detect which one the player is picking up? If I put the script on all the objects?
You can for example call some player function sending as a parameter item's name or whole object itself.
Your answer
Follow this Question
Related Questions
specifying collider OnTriggerEnter 1 Answer
Instantiate spawns 2 instead of 1, help? 2 Answers
Mission Objectives 1 Answer
How can I detect if box is touching a tag named weapon? 1 Answer
Next LEVEL Load Problem. 2 Answers