camera follow
public Transform player;
public Vector3 offset;
void LateUpdate()
{
transform.position = player.position + offset;
}
camera follow
public Transform player;
public Vector3 offset;
void LateUpdate()
{
transform.position = player.position + offset;
}
how to code a move camera in unity
void Update()
{
if(Input.GetKey(KeyCode.RightArrow))
{
transform.Translate(new Vector3(speed * Time.deltaTime,0,0));
}
if(Input.GetKey(KeyCode.LeftArrow))
{
transform.Translate(new Vector3(-speed * Time.deltaTime,0,0));
}
if(Input.GetKey(KeyCode.DownArrow))
{
transform.Translate(new Vector3(0,-speed * Time.deltaTime,0));
}
if(Input.GetKey(KeyCode.UpArrow))
{
transform.Translate(new Vector3(0,speed * Time.deltaTime,0));
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us