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); } }
public void RegisterSteeringBehaviour(SteeringBehaviour2D behaviour) { SteeringBehaviours.Add(behaviour); if (behaviour is ITargettedSteeringBehaviour) { TargettedSteeringBehaviours.Add((ITargettedSteeringBehaviour)behaviour); } if (behaviour.RequiresNeighborList) { behavioursRequiringNeighbors++; } }