player interact with cola freezer, improvement in movements
This commit is contained in:
@@ -38,7 +38,9 @@ public class Player : MonoBehaviour
|
||||
[SerializeField]
|
||||
public Animator _animator;
|
||||
|
||||
private bool _isAllowMovement;
|
||||
[SerializeField]
|
||||
private Transform _holdPoint;
|
||||
|
||||
private AnimationStates _currentAnimation;
|
||||
private Vector3 _groundDeltaPosition;
|
||||
|
||||
@@ -50,6 +52,8 @@ public class Player : MonoBehaviour
|
||||
|
||||
private const string WALK_VELOCITY = "WalkVelocity";
|
||||
|
||||
private FoodObject _foodObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance != null)
|
||||
@@ -62,7 +66,6 @@ public class Player : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
TimeManager.OnMinuteChanged += UpdateStatsByClock;
|
||||
_isAllowMovement = true;
|
||||
_navAgent.updatePosition = false;
|
||||
Stats = PlayerStats.CreateInitialStats();
|
||||
}
|
||||
@@ -117,6 +120,23 @@ public class Player : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFoodObject(FoodObject foodObject)
|
||||
{
|
||||
foodObject.transform.parent = _holdPoint;
|
||||
foodObject.transform.localPosition = Vector3.zero;
|
||||
_foodObject = foodObject;
|
||||
Debug.Log($"player hold {foodObject.GetFoodObjectSO().name}");
|
||||
|
||||
}
|
||||
public FoodObject GetFoodObject()
|
||||
{
|
||||
return _foodObject;
|
||||
}
|
||||
public void ClearFoodObject()
|
||||
{
|
||||
_foodObject = null;
|
||||
}
|
||||
|
||||
private TaskStatus MoveToPoint()
|
||||
{
|
||||
SetPlayerAnimation(AnimationStates.Walking);
|
||||
@@ -151,13 +171,18 @@ public class Player : MonoBehaviour
|
||||
Quaternion rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target), 10 * Time.deltaTime);
|
||||
rotation.x = 0;
|
||||
transform.rotation = rotation;
|
||||
if (targetRot == transform.rotation)
|
||||
if (IsApproximate(targetRot, transform.rotation, 0.000004f))
|
||||
{
|
||||
return TaskStatus.Complete;
|
||||
}
|
||||
return TaskStatus.InProgress;
|
||||
}
|
||||
|
||||
public static bool IsApproximate(Quaternion q1, Quaternion q2, float precision)
|
||||
{
|
||||
return Mathf.Abs(Quaternion.Dot(q1, q2)) >= 1 - precision;
|
||||
}
|
||||
|
||||
private TaskStatus InteractWithObject(BaseInteractableObject interactableObject)
|
||||
{
|
||||
interactableObject.Interact(this);
|
||||
|
||||
Reference in New Issue
Block a user