Search Unity

Disable friendly fire

Discussion in 'Getting Started' started by drdenner, Dec 4, 2015.

  1. drdenner

    drdenner

    Joined:
    Jun 24, 2014
    Posts:
    32
    Object Pooler
    public static Dictionary<string, List<GameObject>> pool = new Dictionary<string, List<GameObject>> ();
    The Pooler contains some "bullets" to be fired.

    Im activating an Object from the Pooler like this
    PoolManager.pool [prefabName] .SetActive (true);
    This activate a bullet

    The Bullet has an
    OnTriggerEnter()

    The problem
    Both the Player and the Enemies use the same Pool, but how do i tell the Bullet who shot it, so that Enemies dont shot eachother?

    And how do i format Code on the forum?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Last question first: formatting code is easy if you use the "Insert" button (in the toolbar between the movie filmstrip and the floppy disk).

    Next: when you activate the bullet object, you will need to also change it in some way — assign it a new Layer or Tag, or get whatever component represents "bulletness" or "which team I'm on" in your game, and tell it which it is.