]> git.cameronkatri.com Git - gmtk-gamejam.git/blob - Assets/Scripts/Controllers/CameraController.cs
Add VFX
[gmtk-gamejam.git] / Assets / Scripts / Controllers / CameraController.cs
1 using UnityEngine;
2
3 namespace Controllers
4 {
5 public class CameraController : MonoBehaviour
6 {
7 [SerializeField] private Transform target;
8 [SerializeField] private float speed;
9 [SerializeField] private GameController game;
10
11 private void FixedUpdate()
12 {
13 if (game.player.IsShooting || game.enemy.IsShooting) // Track the ball when they shoot
14 transform.position = Vector3.MoveTowards(transform.position, new Vector3(game.ball.transform.position.x, game.ball.transform.position.y, -10f), Time.deltaTime * speed);
15 else // Track the player otherwise
16 transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10f), Time.deltaTime * speed);
17 }
18 }
19 }