At the moments i am using theese. But i dont wanna go diagonally, only go in 4 directions. How to do that?
Userplayer.cs
public override void TurnUpdate ()
{
if (Vector3.Distance(moveDestination, transform.position) > 0.1f) {
transform.position += (moveDestination - transform.position).normalized * moveSpeed * Time.deltaTime;
if (Vector3.Distance(moveDestination, transform.position) <= 0.1f) {
transform.position = moveDestination;
GameManager.instance.nextTurn();
}
}
base.TurnUpdate ();
}
}
GameManager.cs
// Update is called once per frame
void Update () {
players[currentPlayerIndex].TurnUpdate();
}
public void nextTurn() {
if (currentPlayerIndex + 1 < players.Count) {
currentPlayerIndex++;
} else {
currentPlayerIndex = 0;
}
}
public void moveCurrentPlayer(Tile destTile) {
players[currentPlayerIndex].moveDestination = destTile.transform.position + 0.95f * Vector3.up;
}
Player.cs
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public Vector3 moveDestination;
public float moveSpeed = 10.0f;
void Awake () {
moveDestination = transform.position;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public virtual void TurnUpdate () {
}
}