Search Unity

Can collision detection only be done on scripts attached to the object you want to collide?

Discussion in 'Scripting' started by RealMcCoyGames, Oct 27, 2020.

  1. RealMcCoyGames

    RealMcCoyGames

    Joined:
    Jul 23, 2018
    Posts:
    65
    So can stuff like OnCollisionEnter and OnTriggerEnter only be done on scripts attached to the actual game object?

    I am a beginner if you can't tell from the question!

    Thanks
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Yes, those message are only sent to script on the same object.

    If needed, you can attach a small "message forwarder" script that can call methods on another object when it receives the messages.
     
    RealMcCoyGames likes this.
  3. RealMcCoyGames

    RealMcCoyGames

    Joined:
    Jul 23, 2018
    Posts:
    65