Improved detective board system
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Unheimlich.Gameplay.Items
|
||||
private Rigidbody _rigidbody;
|
||||
private bool _isAnimationPlaying = false;
|
||||
private ObjectDescriptionTrigger _objectDescriptionTrigger;
|
||||
private LevitatingObject _levitatingObject;
|
||||
|
||||
public bool IsAnimationPlaying => _isAnimationPlaying;
|
||||
|
||||
@@ -37,6 +38,7 @@ namespace Unheimlich.Gameplay.Items
|
||||
_originalParent = transform.parent;
|
||||
|
||||
_objectDescriptionTrigger = GetComponent<ObjectDescriptionTrigger>();
|
||||
_levitatingObject = GetComponent<LevitatingObject>();
|
||||
}
|
||||
|
||||
public override void Interact(GameObject interactor)
|
||||
@@ -75,7 +77,12 @@ namespace Unheimlich.Gameplay.Items
|
||||
_rigidbody.isKinematic = true;
|
||||
transform.SetParent(holdPoint);
|
||||
transform.localPosition = Vector3.forward * _inspectionDistance;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
|
||||
if (_levitatingObject != null)
|
||||
{
|
||||
_levitatingObject.UpdateBasePosition();
|
||||
}
|
||||
}
|
||||
|
||||
public void Release()
|
||||
@@ -85,6 +92,11 @@ namespace Unheimlich.Gameplay.Items
|
||||
transform.rotation = _originalRotation;
|
||||
|
||||
_rigidbody.isKinematic = true;
|
||||
|
||||
if (_levitatingObject != null)
|
||||
{
|
||||
_levitatingObject.UpdateBasePosition();
|
||||
}
|
||||
}
|
||||
|
||||
public float RotationSpeed => _rotationSpeed;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unheimlich.Gameplay.Items
|
||||
{
|
||||
public class LevitatingObject : MonoBehaviour
|
||||
{
|
||||
[Header("Levitation Settings")]
|
||||
[SerializeField] private float _levitationHeight = 0.5f;
|
||||
[SerializeField] private float _levitationSpeed = 1f;
|
||||
|
||||
[Header("Rotation Settings")]
|
||||
[SerializeField] private float _rotationSpeed = 30f;
|
||||
[SerializeField] private Vector3 _rotationAxis = Vector3.up;
|
||||
|
||||
private Vector3 _startLocalPosition;
|
||||
private float _timeOffset;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_startLocalPosition = transform.localPosition;
|
||||
_timeOffset = Random.Range(0f, Mathf.PI * 2f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float yOffset = Mathf.Sin((Time.time + _timeOffset) * _levitationSpeed) * _levitationHeight;
|
||||
transform.localPosition = _startLocalPosition + new Vector3(0f, yOffset, 0f);
|
||||
|
||||
transform.Rotate(_rotationAxis.normalized, _rotationSpeed * Time.deltaTime, Space.World);
|
||||
}
|
||||
|
||||
public void UpdateBasePosition()
|
||||
{
|
||||
_startLocalPosition = transform.localPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 899101746b780fa4ca1a66d0af13173c
|
||||
Reference in New Issue
Block a user