Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using MoreMountains.TopDownEngine;
- public class GridCharacterPathfinder3DWTurns : GridCharacterPathfinder3D
- {
- CharacterGridMovement characterGridMovment;
- protected override void Awake()
- {
- base.Awake();
- characterGridMovment = GetComponent<CharacterGridMovement>();
- }
- protected override void MoveController()
- {
- if (Target == null || NextWaypointIndex <= 0)
- characterGridMovment.SetMovement(Vector2.zero);
- else
- {
- _direction = Waypoints[NextWaypointIndex] - transform.position;
- if (Mathf.Abs(_direction.x) > Mathf.Abs(_direction.z))
- {
- _newMovement.x = _direction.x;
- _newMovement.y = 0;
- }
- else
- {
- _newMovement.x = 0;
- _newMovement.y = _direction.z;
- }
- //x = negative we move left
- //x = positive we move right
- //y = negative we move down
- //y = positive we move up
- if(_newMovement.x <0f)
- {
- characterGridMovment.LeftOneCell();
- waitTillNextTurn();
- }else
- if(_newMovement.x > 0f)
- {
- characterGridMovment.RightOneCell();
- waitTillNextTurn();
- }
- if(_newMovement.y <0f)
- {
- characterGridMovment.DownOneCell();
- waitTillNextTurn();
- }else
- if(_newMovement.y>0f)
- {
- characterGridMovment.UpOneCell();
- waitTillNextTurn();
- }
- //characterGridMovment.SetMovement(_newMovement);
- }
- }
- private void waitTillNextTurn()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement