public static BulletBehavior Build(SubjectBehavior subject)
        {
            BulletBehavior bullet = subject.gameObject.AddComponent <BulletBehavior>();

            bullet.subject = subject;
            return(bullet);
        }
Beispiel #2
0
        private void Fire()
        {
            var bullet = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            bullet.transform.localScale = Vector3.one * .4f;
            bullet.transform.position   = bulletSpawn.position;

            BulletBehavior.Build(SubjectBehavior.Build(bullet, recorder, "Bullet"));

            var rb = bullet.AddComponent <Rigidbody>();

            rb.velocity = transform.forward * 15;
            rb.mass     = 3;

            Destroy(bullet, 5);
            bulletsFired++;
            subjectBehavior.SetMetaData("Bullets Fired", bulletsFired.ToString());
        }