Moving an object with vector3.MoveTowards

后端 未结 2 1713
挽巷
挽巷 2021-01-22 06:37

I am working on a game app with Unity. I have an issue when it comes to move a GameObject .

In my game, when the player swipes up with his device, the GameObject moves f

2条回答
  •  忘掉有多难
    2021-01-22 07:06

    Here is how to use MoveTowards:

    void Update()
    {
        float step = speed * Time.deltaTime;
        transform.position = Vector3.MoveTowards(transform.position, PositionB, step);
    }
    

    LearnMore

提交回复
热议问题