Answer the question
In order to leave comments, you need to log in
How to make an object move along certain coordinates?
Hello, I want to make the movement of the game object along the given coordinates, namely: so that the object moves to the coordinate for example 1; 0 from the coordinate 0; 0, and then when it reaches this coordinate, it moves vice versa to the initial coordinate 0; 0, and so constantly like opponents in mario. I made the object move to the given coordinate, but I can't make the object move backwards and put it all in a loop. Here is the code:
public class blockmove : MonoBehaviour
{
void Update()
{
gameObject.transform.position = new Vector2(gameObject.transform.position.x + 2 * Time.deltaTime, gameObject.transform.position.y);
}
}
Answer the question
In order to leave comments, you need to log in
Vector3.MoveTowards - movement to the object
When reached, check the point and set the true flag, and back, and so constantly
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question