移除ECM2
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ECM2.Examples.TwinStickMovement
|
||||
{
|
||||
/// <summary>
|
||||
/// This example shows how to extend a Character (through inheritance), adding a custom rotation mode;
|
||||
/// in this case, implements a typical Mouse and Keyboard twin-stick shooter control.
|
||||
/// </summary>
|
||||
|
||||
public class TwinStickCharacter : Character
|
||||
{
|
||||
private Vector3 _aimDirection;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current aim direction vector.
|
||||
/// </summary>
|
||||
|
||||
public virtual Vector3 GetAimDirection()
|
||||
{
|
||||
return _aimDirection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the desired aim direction vector (in world space).
|
||||
/// </summary>
|
||||
|
||||
public virtual void SetAimDirection(Vector3 worldDirection)
|
||||
{
|
||||
_aimDirection = worldDirection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use a custom rotation mode to rotate towards aim direction (if shooting)
|
||||
/// or towards movement direction if not.
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">The simulation delta time</param>
|
||||
|
||||
protected override void CustomRotationMode(float deltaTime)
|
||||
{
|
||||
// Call base method implementation
|
||||
|
||||
base.CustomRotationMode(deltaTime);
|
||||
|
||||
// Update character rotation
|
||||
|
||||
Vector3 targetDirection =
|
||||
_aimDirection.isZero() ? GetMovementDirection() : GetAimDirection();
|
||||
|
||||
RotateTowards(targetDirection, deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac9b54624973406418996032df376cf9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,51 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace ECM2.Examples.TwinStickMovement
|
||||
{
|
||||
/// <summary>
|
||||
/// This example shows how to implement a basic twin-stick movement.
|
||||
/// This implements a typical Mouse and Keyboard twin-stick shooter control.
|
||||
/// </summary>
|
||||
|
||||
public class TwinStickInput : CharacterInput
|
||||
{
|
||||
private TwinStickCharacter _twinStickCharacter;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
_twinStickCharacter = character as TwinStickCharacter;
|
||||
}
|
||||
|
||||
protected override void HandleInput()
|
||||
{
|
||||
// Call base method implementation
|
||||
|
||||
base.HandleInput();
|
||||
|
||||
// Calc aim direction
|
||||
|
||||
Vector3 aimDirection = Vector3.zero;
|
||||
|
||||
if (Mouse.current.leftButton.isPressed)
|
||||
{
|
||||
// Convert mouse screen position to world position
|
||||
|
||||
Ray ray = character.camera.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out RaycastHit hitResult, Mathf.Infinity))
|
||||
{
|
||||
// Compute aim direction vector (character direction -> mouse world position)
|
||||
|
||||
Vector3 toHitPoint2D = (hitResult.point - character.GetPosition()).onlyXZ();
|
||||
aimDirection = toHitPoint2D.normalized;
|
||||
}
|
||||
}
|
||||
|
||||
// Set Character's aim direction
|
||||
|
||||
_twinStickCharacter.SetAimDirection(aimDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6169cf0ce08c6a44a8fcfdecee15e1e6
|
||||
Reference in New Issue
Block a user