Beispiel #1
0
    public GameObject Spawn()
    {
        Collider[] hit = Physics.OverlapSphere(this.transform.position + thisCollider.center, thisCollider.radius, collisionMask);
        if (hit.Length > 0)
        {
            //Debug.Log("Blocked"+hit[0]);
            return(null);
        }

        spawned = Instantiate(prefab, this.transform.position, this.transform.rotation) as GameObject;
        ThirdPersonUserControl user = spawned.GetComponent <ThirdPersonUserControl>();
        Actor actor = spawned.GetComponent <Actor>();
        Item  item  = spawned.GetComponent <Item>();

        switch (spawnType)
        {
        case SpawnType.ACTOR_PC:
            user.Spawn(true);
            actor.Spawn(team, true);
            break;

        case SpawnType.ACTOR_AI:
            user.Spawn(false);
            actor.Spawn(team, false);
            break;

        default:
        case SpawnType.ITEM:
            item.Spawn();
            break;
        }
        return(spawned);
    }