S
S
Shallmick2021-04-20 22:24:56
Unity
Shallmick, 2021-04-20 22:24:56

How to make it so that the camera does NOT follow the player along the axis up and down (only left and right)?

Here is the code in case you need it:

public class camera : MonoBehaviour
{
float speed = 3f;
public Transform target;
void Start()
{
transform.position = new Vector3(target.transform.position.x, target.transform.position.y, transform.position.z);
}

void Update()
{
Vector3 position = target.position;
position.z = transform.position.z;
transform.position = Vector3.Lerp(transform.position, position, speed * Time.deltaTime);

}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ReyGrau, 2021-04-20
@Alexander_020

Vector3 position = new Vector3(target.position.x, transform.position.y,transform.position.z);
transform.position = Vector3.Lerp(transform.position, position, speed * Time.deltaTime);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question