You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
756 B

using Ai;
using UnityEngine;
namespace Utils
{
public class TargetPosition : MonoBehaviour
{
[SerializeField] private GameObject _target;
[SerializeField] private float _speed;
[SerializeField] private float _offset;
[SerializeField] private bool _onlyVertical;
[SerializeField] private Vector2 _lock;
private void Update()
{
var newPosition = AiController.Instance.PlayerPosition;
newPosition.y = transform.position.y;
newPosition.z += _offset;
newPosition.z = newPosition.z < _lock.x ? _lock.x : newPosition.z > _lock.y ? _lock.y : newPosition.z;
if (_onlyVertical)
newPosition.x = transform.position.x;
transform.position = Vector3.Lerp(transform.position, newPosition, _speed * Time.deltaTime);
}
}
}