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

Projectile Collision

Discussion in 'Scripting' started by GameDevRick, Mar 29, 2013.

  1. GameDevRick

    GameDevRick

    Joined:
    Oct 8, 2011
    Posts:
    269
    Not sure why this isn't working..
    The projectile just seems to orbit around the target.

    Code (csharp):
    1.  
    2. void OnCollisionEnter(Collision other) {
    3.        
    4.     if(other.collider.tag == "RangedTarget"){
    5.    
    6.         _shot = false;
    7.            
    8.         Destroy(this.gameObject);
    9.     }
    10. }
    In the update, the projectile just moves and alters it's facing direction if the _shot variable is true.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Try adding this line before: if (..

    Code (csharp):
    1. Debug.Log(other.collider.tag);
    Does it print anything?
     
  3. GameDevRick

    GameDevRick

    Joined:
    Oct 8, 2011
    Posts:
    269
    No it doesn't.
    I had the projectile collider tagged as a trigger by mistake.
    Thank you.
     
    Last edited: Mar 30, 2013