Ashby Issac fbeac39eb3 Gameplay system changes.
completed prototyping.
Integrated abstraction layer from previous project.
Refactored gameplay code.
Found an issue with drifting and added a quick fix for the same.
Added camera system for chasing player movement.
2026-01-05 19:59:43 +05:30

29 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowCam : MonoBehaviour
{
public Transform target;
public Transform followPoint;
public Vector3 offset = new Vector3(0f, 5f, -10f);
public float smoothSpeed = 5f;
/*
Summary:
Using fixed update due to cam jittering while using late update
*/
void FixedUpdate()
{
if (target == null) return;
Vector3 rotatedOffset = Quaternion.Euler(0, target.eulerAngles.y, 0) * offset;
Vector3 targetPositonForCam = target.position + rotatedOffset;
transform.position = Vector3.Lerp(transform.position, targetPositonForCam, smoothSpeed * Time.deltaTime);
Quaternion updatedRotation = Quaternion.LookRotation(target.position - transform.position);
updatedRotation = Quaternion.Euler(updatedRotation.eulerAngles.x, updatedRotation.eulerAngles.y, updatedRotation.eulerAngles.z);
transform.rotation = Quaternion.Slerp(transform.rotation, updatedRotation, smoothSpeed * Time.deltaTime);
}
}