I’m working on a dungeon crawler kind of game(Dungeon Master style) and I’m stuck now at making the player going toward a specific direction.
I’ll try to explain what I’ve done until now, instead of using the method on the wiki about the Grid based movements with Horizontal and Vertical axes, I’ve been using a raycast method to check for the next tile.
The raycasts cast on all fourth direction only when a gui button is pressed, so I’m not using any input type of control. The raycast check the next tile that have another script with just a bool if is empty or not, and if is empty you can advance.
Now I’m stuck on my coroutine that should run the move for the player, it all checks good and all, but I can’t menage to make the player move.
I’ve been reading that I should use Vector3.Lerp, by using and start and ending position for the movement, for the start position there is no prob I set it just on transform.position, but I have no idea how to calculate the ending position.
Thats my coroutine:
public IEnumerator MovePlayer (string dir) {
_startPoint = transform.position;
if(!_isMoving){
_isMoving = true;
if(dir == "forward"){
Debug.Log ("MOVE FORWARD");
}
else if(dir == "backward"){
Debug.Log ("MOVE BACKWARD");
}
else if(dir == "left"){
Debug.Log ("MOVE LEFT");
}
else if(dir == "right"){
Debug.Log ("MOVE RIGHT");
}
while (true) {
yield return null;
}
_isMoving = false;
}
}
Is nothing fancy, but I don’t know how to set up the whole thing to actual move the player, any help would be appreciated.