public void Spawn(Weapon weapon, Agent shooter, Vector3 targetPosition)
        {
            var heightOffset = Vector3.up * 0.3f; // raise up to shoot over low walls

            Spawn(weapon, shooter, shooter.Kinematic.Position + heightOffset, targetPosition,
                  Parameters.Instance.RocketDamage);

            name                   = "ROCKET_" + id;
            EntityType             = EntityTypes.Rocket;
            IsAiControlled         = true;
            Kinematic.MaximumSpeed = Parameters.Instance.RocketMaximumSpeed;

            var directionToTarget = (targetPosition - (shooter.Kinematic.Position + heightOffset)).normalized;

            var transform1 = transform;

            transform1.position =
                shooter.Kinematic.Position + heightOffset + directionToTarget * shooter.Kinematic.Radius;
            transform1.localScale = new Vector3(0.25f, 0.5f, 0.25f);
            transform.LookAt(targetPosition);
            transform.Rotate(Vector3.right, 90);

            if (Parameters.Instance.RocketIsHeatSeeking)
            {
                SteeringBehaviours.Add(new Seek(Kinematic, shooter.TargetingSystem.Target.Kinematic));
            }
            else
            {
                Kinematic.SetVelocity(directionToTarget * Parameters.Instance.RocketMaximumSpeed);
            }
        }
Exemplo n.º 2
0
        public void Spawn(Weapon weapon, Agent shooter, Vector3 targetPosition)
        {
            var heightOffset = Vector3.up * 0.3f; // raise up to shoot over low walls

            Spawn(weapon, shooter, shooter.Kinematic.Position + heightOffset, targetPosition,
                  Parameters.Instance.PelletDamage);

            name                   = "PELLET_" + id;
            EntityType             = EntityTypes.Pellet;
            IsAiControlled         = true;
            Kinematic.MaximumSpeed = Parameters.Instance.PelletMaximumSpeed;

            var directionToTarget = (targetPosition - (shooter.Kinematic.Position + heightOffset)).normalized;

            var transform1 = transform;

            transform1.position =
                shooter.Kinematic.Position + heightOffset + directionToTarget * shooter.Kinematic.Radius;
            transform1.localScale = new Vector3(0.5f, 0.5f, 0.5f);

            Kinematic.SetVelocity(directionToTarget * Parameters.Instance.PelletMaximumSpeed);
        }