Beispiel #1
0
    void shootBullet()
    {
        GameObject bullet = Instantiate(bulletPrefab, transform.position + bulletStartPosition, Quaternion.identity);

        // set color
        // set physical layer
        bullet.GetComponent <Renderer>().material.color = ColorLayerInfo.GetColorByLayerName(color);
        bullet.layer = LayerMask.NameToLayer(color);
        Rigidbody2D rb;

        rb          = bullet.GetComponent <Rigidbody2D>() as Rigidbody2D;
        rb.velocity = bulletInitialVelocity;
        bullet.GetComponent <Bullet>().lifeTime = bulletLifeTime;
    }
Beispiel #2
0
 void updateLayerAndColor(string layerName)
 {
     gameObject.layer = LayerMask.NameToLayer(layerName);
     gameObject.GetComponent <Renderer>().material.color = ColorLayerInfo.GetColorByLayerName(layerName);
 }