- Added InteractionTimelineAction component for timeline-driven interactions - Implemented custom editor for timeline event mapping - Updated interaction event flow to support timeline actions - Enhanced character move target configuration - Improved inspector UI for interactable components - Added technical documentation for interaction system - Refactored interaction action base classes for extensibility - Fixed issues with character binding in timelines Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #17
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
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
|
|
}
|
|
}
|