//Seeks around the map via following checkpoints
    public override void Seek()
    {
        if (_targetCheckpoint == null)
            return;
        trigger_.IsTriggered = losDetector_.DetectTargets ();
        _direction = _targetCheckpoint.Position - this.transform.position;

        if (!_targetCheckpoint.Reached (this.transform.position)) {
            _slerpValue += Time.deltaTime * rotationSpeed;
            _slerpValue = Mathf.Clamp01(_slerpValue);
            this.transform.position += _direction.normalized * Time.deltaTime * movementSpeed; //change to speed
            float angle = Mathf.Atan2(-_direction.z,_direction.x) * Mathf.Rad2Deg;
            Quaternion rotation = Quaternion.AngleAxis(angle,Vector3.up);
            transform.rotation = Quaternion.Slerp(_rotationAtLastCheckpoint, rotation,_slerpValue);
            return;
        }

        _slerpValue = 0;
        //if action at checpoint isn't complete then leave
        if (!_targetCheckpoint.ApplyCheckpointAction (this.transform))
            return;

        //Store new values fro moving to next checkpoint
        _rotationAtLastCheckpoint = transform.rotation;
        _targetCheckpoint = _targetCheckpoint.AdjacentCheckpoint;
        _direction = _targetCheckpoint.Position - this.transform.position;
    }
        void Awake()
        {
            instance = this;
            Grass    = _Grass;
            Pavement = _Pavement;
            Straight = _Straight;
            Corner   = _Corner;
            T        = _T;

            DeadEnd = _DeadEnd;
            FourWay = _FourWay;

            checkpoint = _Checkpoint;

            bCull = _Cull;

            //TimeUntilFieldCheck = MaxTimeUntilFieldCheck;

            bMainMenu = _MainMenu;

            bDebugEnv = Application.platform == RuntimePlatform.WindowsEditor;

            hitTest    = new TilePosition();
            roundedVec = new Vector3();
        }
Beispiel #3
0
 public void AddCheckpointToPath(BaseCheckpoint newCheckpoint)
 {
     checkpoints.Add (newCheckpoint);
 }
 void Start()
 {
     checkpoint    = GameObject.Find("CheckpointManager").GetComponent <BaseCheckpoint>();
     followCam     = checkpoint.FollowCamera;
     displayRadius = GetComponent <RectTransform>().rect.width / 2;
 }