while I'm studying Unity and C# (Unity Learn), I was looking for tips around this: how can I change Point of View with only One Camera? Is it possible?
Here my code, attached to the MainCamera:
public class FollowPlayer : MonoBehaviour
{
public GameObject plane;
private Vector3 offset = new Vector3(0, 13, -13);
private Vector3 change = new Vector3(0, 10, -10);
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void LateUpdate()
{
// Follow the player
transform.position = plane.transform.position + offset;
if (Input.GetAxis("Fire1") != 0)
{
transform.position = plane.transform.position + change;
}
if (Input.GetAxis("Fire2") != 0)
{
transform.position = plane.transform.position + offset;
}
}
}
What I want to do is to switch the "new Vector3" position of my Camera when I press a Button (Fire1 or Fire2)... It works just when I hold the Fire1/2 button. How can I say to Unity to hold the position linked to the button Fire1 or Fire2?
What am I doing wrong?
Thanks