Add Synty Animation - Base Locomotion pack
Vendored Synty clip library (idle/walk/run/sprint, full 8-way strafe, turns, transitions) that drives the player animation pipeline. See DR-022. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
// Copyright (c) 2024 Synty Studios Limited. All rights reserved.
|
||||
//
|
||||
// Use of this software is subject to the terms and conditions of the Synty Studios End User Licence Agreement (EULA)
|
||||
// available at: https://syntystore.com/pages/end-user-licence-agreement
|
||||
//
|
||||
// Sample scripts are included only as examples and are not intended as production-ready.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Synty.AnimationBaseLocomotion.Samples.InputSystem
|
||||
{
|
||||
public class InputReader : MonoBehaviour, Controls.IPlayerActions
|
||||
{
|
||||
public Vector2 _mouseDelta;
|
||||
public Vector2 _moveComposite;
|
||||
|
||||
public float _movementInputDuration;
|
||||
public bool _movementInputDetected;
|
||||
|
||||
private Controls _controls;
|
||||
|
||||
public Action onAimActivated;
|
||||
public Action onAimDeactivated;
|
||||
|
||||
public Action onCrouchActivated;
|
||||
public Action onCrouchDeactivated;
|
||||
|
||||
public Action onJumpPerformed;
|
||||
|
||||
public Action onLockOnToggled;
|
||||
|
||||
public Action onSprintActivated;
|
||||
public Action onSprintDeactivated;
|
||||
|
||||
public Action onWalkToggled;
|
||||
|
||||
/// <inheritdoc cref="OnEnable" />
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_controls == null)
|
||||
{
|
||||
_controls = new Controls();
|
||||
_controls.Player.SetCallbacks(this);
|
||||
}
|
||||
|
||||
_controls.Player.Enable();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="OnDisable" />
|
||||
public void OnDisable()
|
||||
{
|
||||
_controls.Player.Disable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnLook callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnLook(InputAction.CallbackContext context)
|
||||
{
|
||||
_mouseDelta = context.ReadValue<Vector2>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnMove callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnMove(InputAction.CallbackContext context)
|
||||
{
|
||||
_moveComposite = context.ReadValue<Vector2>();
|
||||
_movementInputDetected = _moveComposite.magnitude > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnJump callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if (!context.performed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
onJumpPerformed?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnToggleWalk callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnToggleWalk(InputAction.CallbackContext context)
|
||||
{
|
||||
if (!context.performed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
onWalkToggled?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnSprint callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnSprint(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
{
|
||||
onSprintActivated?.Invoke();
|
||||
}
|
||||
else if (context.canceled)
|
||||
{
|
||||
onSprintDeactivated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnCrouch callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnCrouch(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
{
|
||||
onCrouchActivated?.Invoke();
|
||||
}
|
||||
else if (context.canceled)
|
||||
{
|
||||
onCrouchDeactivated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnAim callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnAim(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.started)
|
||||
{
|
||||
onAimActivated?.Invoke();
|
||||
}
|
||||
|
||||
if (context.canceled)
|
||||
{
|
||||
onAimDeactivated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the action to perform when the OnLockOn callback is called.
|
||||
/// </summary>
|
||||
/// <param name="context">The context of the callback.</param>
|
||||
public void OnLockOn(InputAction.CallbackContext context)
|
||||
{
|
||||
if (!context.performed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
onLockOnToggled?.Invoke();
|
||||
onSprintDeactivated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user