There is a certain area ("Map") on which certain objects are scattered, between the objects there are several objects of points (indicator of the path, the number of points is different). The ship object moves along this path. How can I make a smooth movement of the camera along with the movement of the ship object (He, to my sadness, only "teleports" points)

Ideally, how to make a smooth movement of both ship and camera

The following code is available:

StartCoroutine(movement()); public IEnumerator movement() { var cam_top_y = Camera.main.transform.position.y - Camera.main.orthographicSize; var cam_bottom_y = Camera.main.transform.position.y + Camera.main.orthographicSize; foreach (Transform item in movement.points_active.transform) { ship.transform.position = item.transform.position; break; } ship.SetActive(true); yield return new WaitForSeconds(1.3f); movement.points_active.SetActive(true); foreach (Transform item in movement.points_active.transform) { item.gameObject.SetActive(true); ship.transform.position = item.position; /*if ((cam_top_y > sca.MaxY) && (cam_bottom_y < sca.MinY)) { cam.transform.Translate(0, item.transform.position.y, 0); }*/ yield return new WaitForSeconds(0.1f); } yield return null; } 

1 answer 1

It is necessary not only to change the position, but taking into account time. Ways to do it in full. https://docs.unity3d.com/ScriptReference/Transform.Translate.html

Here is a video where the movement is also "by the points". https://www.youtube.com/watch?v=b7DZo4jA3Jo

I did not understand the question about the camera. In general, the material on the movement of the object and the camera is complete.

  • My main problem is to make the camera move parallel while the ship is moving. The camera should move from 1 one object (say, cities) to another (in my case, only in the y coordinate). - Slimper
  • one
    @Slimper so why not bind the camera to the ship and change its delta? as in the link that I gave - Alexey Shimansky