Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerFollow : MonoBehaviour
{
public GameObject player;
private Vector3 offset;
private bool switch;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void LateUpdate()
{
switch = Input.GetButton("Fire1");
if (switch == true)
{
offset = new Vector3(0, 2, 1);
}
else
{
offset = new Vector3(0, 8, -7.5f);
}
transform.position = player.transform.position + offset;
}
}