Answer the question
In order to leave comments, you need to log in
How to stop the movement of an object on a checkerboard when it reaches the edge of the field?
Good afternoon, roughly speaking, there is a chessboard, you need to move the object from one edge to the other (if there is an obstacle along the way, we slow down the object).
And so, it seems the task is simple, we move:
float speed = 30f;
bool isMove = false;
void Upload(){
if(isMove) // true когда мы нажали кнопку "вперед"
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
void OnTriggerEnter(Collider collider)
{
if (collider.tag == "Obstacles")
{
Debug.Log("STOP");
isMove = false;
}
}
Answer the question
In order to leave comments, you need to log in
Killer auto-chess checkers? Your problem is that you are mixing logic with animation. Chess is a strict discrete single-valued matrix of objects with complete information.
1. Create a matrix
2. Fill the matrix with figures
3. When moving, a new place is stupidly calculated by cells
4. Start the animation "move from point A to point B in time T" MyGameObject[,] =new MyGameObject[4,5]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question