Amazing game ! Completed it and want more
Denys Shust
Creator of
Recent community posts
Please, unhook the camera from the player, make it smoothly follow the player.
The script for the Camera :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
[SerializeField] private Vector3 offset;
[SerializeField] private Transform target;
[SerializeField] private float translateSpeed;
[SerializeField] private float rotateSpeed;
private void FixedUpdate()
{
HandleRotation();
HandleTranslation();
}
private void HandleTranslation()
{
var targetPosition = target.TransformPoint(offset);
transform.position = Vector3.Lerp(transform.position, targetPosition, translateSpeed * Time.deltaTime);
}
private void HandleRotation()
{
var direction = target.position - transform.position;
var rotation = Quaternion.LookRotation(direction, Vector3.up);
transform.rotation = Quaternion.Lerp(transform.rotation, rotation, rotateSpeed * Time.deltaTime);
}
}