Semi-working timelines integration
This commit is contained in:
committed by
Michal Pikulski
parent
c46036dce6
commit
fd611ac27f
58
Assets/Scripts/Interactions/CharacterMoveToTarget.cs
Normal file
58
Assets/Scripts/Interactions/CharacterMoveToTarget.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Interactions
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a target position for character movement during interaction.
|
||||
/// Attach this to an interactable object's child to specify where
|
||||
/// characters should move during interaction rather than using the default calculations.
|
||||
/// </summary>
|
||||
public class CharacterMoveToTarget : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Which character this target position is for")]
|
||||
public CharacterToInteract characterType = CharacterToInteract.Pulver;
|
||||
|
||||
[Tooltip("Optional offset from this transform's position")]
|
||||
public Vector3 positionOffset = Vector3.zero;
|
||||
|
||||
/// <summary>
|
||||
/// Get the target position for this character to move to
|
||||
/// </summary>
|
||||
public Vector3 GetTargetPosition()
|
||||
{
|
||||
return transform.position + positionOffset;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
// Draw a different colored sphere based on which character this target is for
|
||||
switch (characterType)
|
||||
{
|
||||
case CharacterToInteract.Trafalgar:
|
||||
Gizmos.color = new Color(0f, 0.5f, 1f, 0.8f); // Blue for player
|
||||
break;
|
||||
case CharacterToInteract.Pulver:
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.8f); // Orange for follower
|
||||
break;
|
||||
case CharacterToInteract.Both:
|
||||
Gizmos.color = new Color(0.7f, 0f, 0.7f, 0.8f); // Purple for both
|
||||
break;
|
||||
default:
|
||||
Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 0.8f); // Gray for none
|
||||
break;
|
||||
}
|
||||
|
||||
Vector3 targetPos = GetTargetPosition();
|
||||
Gizmos.DrawSphere(targetPos, 0.2f);
|
||||
|
||||
// Draw a line from the parent interactable to this target
|
||||
Interactable parentInteractable = GetComponentInParent<Interactable>();
|
||||
if (parentInteractable != null)
|
||||
{
|
||||
Gizmos.DrawLine(parentInteractable.transform.position, targetPos);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user