Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnTriggerEnter: player or projectile?

Discussion in 'Physics' started by JohnnyFactor, Jun 22, 2019.

  1. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I have a player moving through a field of static "mines". Is it better to have the OnTriggerEnter routine on the player or on each mine? Does it matter?
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    Nope. Do it however way you prefer.

    Personally, I find it makes more sense to have this one specific object trying to detect many other objects, rather than these many other objects trying to detect this one specific object.
     
    JohnnyFactor and SparrowGS like this.
  3. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    In the case that only the player can possibly activate them i'd stick all the logic on him.
     
    JohnnyFactor likes this.
  4. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    Thanks a lot. Yes only the player will trigger them, along with many other types of items in the field.