Search Unity

environnement perseption probleme

Discussion in 'Scripting' started by heiji, Dec 3, 2014.

  1. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    hello,

    for a combat game projet, i try code a environnement perception for character. i have create a trigger around player and i would like use tag for authorize or not a action. for test my trigger, i use this simple script:


    function OnTriggerEnter(other:Collider) {
    Destroy(other.gameObject);
    }

    and, i d'ont understand why, this script work for kill other character, but it doesn't work for other object :/

    have you a idea for this probleme?

    (sorry for my english ^^)
     
  2. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    else, have you a other solution for get what is around the player?
     
  3. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    it's work with character controller, but isn't a good solution for every object. exist other solution?
     
  4. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    OnTriggerEnter only gets called on objects that have a Collider component attached.
     
  5. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    my object have box collider or mesh collider.
     
  6. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    other idea?
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Do the colliders or a parent object of them have a rigidbody?
     
  8. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    i have try with rigidbody and without.
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Are you mixing 2d and 3d colliders?
     
  10. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    3D, i have try with mesh collider and box collider
     
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Has your player a rigidbody?
     
  12. heiji

    heiji

    Joined:
    Sep 22, 2013
    Posts:
    9
    my player have a rigidbody and collider.