feat: Samyaza player controls
This commit is contained in:
@@ -119,6 +119,204 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &51003973
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 51003976}
|
||||
- component: {fileID: 51003975}
|
||||
- component: {fileID: 51003974}
|
||||
- component: {fileID: 51003977}
|
||||
m_Layer: 0
|
||||
m_Name: PlayerDriver
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &51003974
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 51003973}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cc0335304e1f8fc4588964a0aea84656, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: OctoCore.Runtime::OctoCore.Components.OctoPlayerDriver
|
||||
_state:
|
||||
ForcePlayerToFollowTarget: 0
|
||||
MoveInfluence: 0
|
||||
LookInfluence: 0
|
||||
YawRange: 180
|
||||
PitchRange: 90
|
||||
_references:
|
||||
Target: {fileID: 51003976}
|
||||
LookAt: {fileID: 0}
|
||||
_settings:
|
||||
DriveStrength: 1
|
||||
LookAtStrength: 0
|
||||
LookAtSmooth: 1
|
||||
LookAtPoint: 1
|
||||
DriveCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 34
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
LookCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
_events:
|
||||
OnDrive:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnFullInfluence:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
OnRelease:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &51003975
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 51003973}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5170627695bd877419928fa9ca37865d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: OctoCore.Runtime::OctoCore.Components.OctoWorldEvent
|
||||
_trigger: 4
|
||||
_action: 0
|
||||
_condition: 0
|
||||
_tags: []
|
||||
_targets: []
|
||||
_tolerance: 0.5
|
||||
_duration: 1
|
||||
_execution: 0
|
||||
_delay: 1
|
||||
_onTrigger:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 51003974}
|
||||
m_TargetAssemblyTypeName: OctoCore.Components.OctoPlayerDriver, OctoCore.Runtime
|
||||
m_MethodName: DrivePlayer
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
_onTriggerDelayed:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!4 &51003976
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 51003973}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 5.35}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &51003977
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 51003973}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 516425b0868f3994c832b62ccc7be87a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: OctoCore.Runtime::OctoCore.OctoPlayerSpeedArea
|
||||
_settings:
|
||||
MinRadius: 1
|
||||
MaxRadius: 4
|
||||
MinSpeedMultiplier: 0
|
||||
MaxSpeedMultiplier: 1
|
||||
SpeedCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &235456879
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -524,6 +722,18 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5295567073180248356, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
propertyPath: _settings.AllowMove
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5295567073180248356, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
propertyPath: _firstPerson.MaxPitch
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5295567073180248356, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
propertyPath: _firstPerson.MinPitch
|
||||
value: -80
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5295567073180248356, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
propertyPath: _firstPerson.RangeYaw
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6989128982853398086, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
@@ -581,10 +791,7 @@ PrefabInstance:
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 8162540767767967414, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1463885974}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
--- !u!1 &832575517
|
||||
GameObject:
|
||||
@@ -1056,67 +1263,6 @@ PrefabInstance:
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909252592}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: b4c976c60f3fdd341aac54399b120b66, type: 3}
|
||||
--- !u!1 &1463885970 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8162540767767967414, guid: bfb9a06a57603714ca245d62fcd622f1, type: 3}
|
||||
m_PrefabInstance: {fileID: 642044301}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1463885974
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1463885970}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dbf0bbf614111884293442c3a123e5d5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OctoCore.Components.OctoProceduralAnimator
|
||||
_state:
|
||||
CurrentTime: 0
|
||||
IsFinished: 0
|
||||
InitialPosition: {x: 0, y: 0, z: 0}
|
||||
InitialRotation: {x: 0, y: 0, z: 0, w: 0}
|
||||
InitialScale: {x: 0, y: 0, z: 0}
|
||||
_settings:
|
||||
Space: 0
|
||||
Type: 3
|
||||
Balance: 1
|
||||
Curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
PlayOnAwake: 1
|
||||
Duration: 20
|
||||
TimeOffset: 0
|
||||
Translation: {x: 0, y: 0, z: 3.5}
|
||||
Rotation: {x: 0, y: 0, z: 0}
|
||||
Scale: {x: 0, y: 0, z: 0}
|
||||
_events:
|
||||
OnAnimationEnded:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1001 &1468790604
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1393,3 +1539,4 @@ SceneRoots:
|
||||
- {fileID: 570896044}
|
||||
- {fileID: 313187240}
|
||||
- {fileID: 536845392}
|
||||
- {fileID: 51003976}
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OctoCore.Components
|
||||
public bool IsRunning;
|
||||
public float Yaw;
|
||||
public float Pitch;
|
||||
public float SpeedMultiplier = 1;
|
||||
public OctoPlayerDriver Driver;
|
||||
}
|
||||
|
||||
@@ -41,6 +42,12 @@ namespace OctoCore.Components
|
||||
[Tooltip("Allow looking around.")]
|
||||
public bool AllowLook = true;
|
||||
|
||||
[Tooltip("Allow run.")]
|
||||
public bool AllowRun = true;
|
||||
|
||||
[Tooltip("Allow jump.")]
|
||||
public bool AllowJump = true;
|
||||
|
||||
[Tooltip("Walk speed (km/h).")]
|
||||
public float WalkSpeed = 10;
|
||||
|
||||
@@ -86,9 +93,15 @@ namespace OctoCore.Components
|
||||
|
||||
[Tooltip("Maximum pitch (looking up).")]
|
||||
public float MaxPitch = 80f;
|
||||
|
||||
[Tooltip("Reference yaw.")]
|
||||
[Range(-180, 180)] public float ReferenceYaw = 0;
|
||||
|
||||
[Tooltip("Range yaw.")]
|
||||
[Range(0, 360)] public float RangeYaw = 360;
|
||||
}
|
||||
|
||||
[OctoReadOnly] public StateMachine State;
|
||||
[SerializeField, OctoReadOnly] private StateMachine _state;
|
||||
[SerializeField] private References _references;
|
||||
[SerializeField] private Settings _settings;
|
||||
[SerializeField] private Mapping _mapping;
|
||||
@@ -107,8 +120,9 @@ namespace OctoCore.Components
|
||||
private Vector3 _moveInertia;
|
||||
private Vector3 _moveDirection;
|
||||
|
||||
public bool IsPaused => State.IsPaused;
|
||||
public bool IsPaused => _state.IsPaused;
|
||||
public float Radius => _references.Controller ? _references.Controller.radius : 0;
|
||||
public StateMachine State => _state;
|
||||
public FirstPerson _FirstPerson => _firstPerson;
|
||||
|
||||
void OnEnable()
|
||||
@@ -121,11 +135,11 @@ namespace OctoCore.Components
|
||||
OctoCore.Instance.Inputs.SubscribeAction(_mapping.RunAction, Run);
|
||||
OctoCore.Instance.Inputs.SubscribeAction(_mapping.JumpAction, Jump);
|
||||
|
||||
State.Yaw = transform.eulerAngles.y;
|
||||
_state.Yaw = transform.eulerAngles.y;
|
||||
|
||||
State.IsFocussed = Application.isFocused;
|
||||
_state.IsFocussed = Application.isFocused;
|
||||
|
||||
Pause(State.IsPaused);
|
||||
Pause(_state.IsPaused);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
@@ -156,12 +170,12 @@ namespace OctoCore.Components
|
||||
|
||||
public void Teleport(Vector3 position, Quaternion rotation)
|
||||
{
|
||||
State.IsPaused = _jumpInput = _jumpping = _runInput = false;
|
||||
_state.IsPaused = _jumpInput = _jumpping = _runInput = false;
|
||||
_runInertia = _jumpLerp = _jumpTime = _jumpAltitude = 0;
|
||||
_moveInput = _lookInput = Vector2.zero;
|
||||
_moveInertia = _moveDirection = Vector3.zero;
|
||||
State.Yaw = rotation.eulerAngles.y;
|
||||
State.Pitch = 0;
|
||||
_state.Yaw = rotation.eulerAngles.y;
|
||||
_state.Pitch = 0;
|
||||
|
||||
if (_references.Controller)
|
||||
_references.Controller.enabled = false;
|
||||
@@ -175,24 +189,26 @@ namespace OctoCore.Components
|
||||
|
||||
public void Pause(bool pause)
|
||||
{
|
||||
State.IsPaused = pause;
|
||||
_state.IsPaused = pause;
|
||||
|
||||
if (OctoCore.Instance)
|
||||
OctoCore.Instance.UI.SetCursor();
|
||||
}
|
||||
|
||||
public void SetSppedMultiplier(float multiplier) { _state.SpeedMultiplier = multiplier; }
|
||||
|
||||
public void AllowMove(bool allow) { _settings.AllowMove = allow; }
|
||||
|
||||
public void Drive(OctoPlayerDriver driver) { State.Driver = driver; }
|
||||
public void ReleaseDrive() { State.Driver = null; }
|
||||
public void Drive(OctoPlayerDriver driver) { _state.Driver = driver; }
|
||||
public void ReleaseDrive() { _state.Driver = null; }
|
||||
|
||||
public void SetYaw(float yaw) { State.Yaw = yaw; }
|
||||
public void SetPitch(float pitch) { State.Yaw = pitch; }
|
||||
public void SetYaw(float yaw) { _state.Yaw = yaw; }
|
||||
public void SetPitch(float pitch) { _state.Yaw = pitch; }
|
||||
|
||||
private void Move(Vector2 value) { _moveInput = value; }
|
||||
private void Look(Vector2 value) { _lookInput = value; }
|
||||
private void Run() { _runInput = true; }
|
||||
private void Jump() { _jumpInput = true; }
|
||||
private void Run() { _runInput = _settings.AllowRun; }
|
||||
private void Jump() { _jumpInput = _settings.AllowJump; }
|
||||
|
||||
private void HandleFocus()
|
||||
{
|
||||
@@ -220,16 +236,16 @@ namespace OctoCore.Components
|
||||
|
||||
if (!Application.isFocused || escapePressed)
|
||||
{
|
||||
if (State.IsFocussed)
|
||||
if (_state.IsFocussed)
|
||||
{
|
||||
State.IsFocussed = false;
|
||||
_wasPausedBeforeUnfocuss = State.IsPaused;
|
||||
_state.IsFocussed = false;
|
||||
_wasPausedBeforeUnfocuss = _state.IsPaused;
|
||||
Pause(true);
|
||||
}
|
||||
}
|
||||
else if (!State.IsFocussed && mouseClicked)
|
||||
else if (!_state.IsFocussed && mouseClicked)
|
||||
{
|
||||
State.IsFocussed = true;
|
||||
_state.IsFocussed = true;
|
||||
if (!_wasPausedBeforeUnfocuss)
|
||||
Pause(false);
|
||||
}
|
||||
@@ -237,7 +253,7 @@ namespace OctoCore.Components
|
||||
|
||||
private void HandleMovement()
|
||||
{
|
||||
_moveInput = (State.IsPaused || !State.IsFocussed || !_settings.AllowMove) ? Vector2.zero : Vector2.ClampMagnitude(_moveInput, 1);
|
||||
_moveInput = (_state.IsPaused || !_state.IsFocussed || !_settings.AllowMove) ? Vector2.zero : Vector2.ClampMagnitude(_moveInput, 1);
|
||||
Camera cam = (_firstPerson.Camera && _firstPerson.Camera.enabled && _firstPerson.Camera.gameObject.activeInHierarchy) ? _firstPerson.Camera : Camera.main;
|
||||
|
||||
bool accelerating = _moveInput.magnitude > .1f;
|
||||
@@ -261,8 +277,8 @@ namespace OctoCore.Components
|
||||
move = camRight * move.x + camForward * move.z;
|
||||
}
|
||||
|
||||
if (State.Driver)
|
||||
State.Driver.ApplyMoveInfluence(move, t, out move);
|
||||
if (_state.Driver)
|
||||
_state.Driver.ApplyMoveInfluence(move, t, out move);
|
||||
|
||||
float deltaSmooth = t * (accelerating ? 30 : 15);
|
||||
_moveDirection = Vector3.Lerp(_moveDirection, move, deltaSmooth * 1.5f);
|
||||
@@ -273,9 +289,9 @@ namespace OctoCore.Components
|
||||
if (!accelerating && _moveInertia.magnitude < .01f) _moveInertia = Vector3.zero;
|
||||
|
||||
_runInertia = Mathf.Lerp(_runInertia, _runInput ? 1 : 0, t * (accelerating ? 5 : 3));
|
||||
State.IsRunning = _runInertia > .1f;
|
||||
_state.IsRunning = _runInertia > .1f;
|
||||
|
||||
Vector3 moveDelta = _moveInertia * t * Mathf.Lerp(_settings.WalkSpeed, _settings.RunSpeed, _runInertia);
|
||||
Vector3 moveDelta = _moveInertia * t * Mathf.Lerp(_settings.WalkSpeed, _settings.RunSpeed, _runInertia) * _state.SpeedMultiplier;
|
||||
|
||||
if (isGrounded && _jumpInput && !_jumpping)
|
||||
{
|
||||
@@ -328,24 +344,29 @@ namespace OctoCore.Components
|
||||
switch (_settings.Mode)
|
||||
{
|
||||
case PlayerModes.FirstPerson:
|
||||
if (cam && !State.IsPaused)
|
||||
if (cam && !_state.IsPaused)
|
||||
{
|
||||
Vector2 delta = (State.IsPaused || !State.IsFocussed) ? Vector2.zero : _lookInput;
|
||||
Vector2 delta = (_state.IsPaused || !_state.IsFocussed) ? Vector2.zero : _lookInput;
|
||||
|
||||
if (_settings.AllowLook)
|
||||
{
|
||||
float mouseX = delta.x * _firstPerson.SensitivityX;
|
||||
float mouseY = delta.y * _firstPerson.SensitivityY * -1;
|
||||
|
||||
State.Yaw += mouseX;
|
||||
State.Pitch = Mathf.Clamp(State.Pitch + mouseY, _firstPerson.MinPitch, _firstPerson.MaxPitch);
|
||||
_state.Yaw += mouseX;
|
||||
float halfRange = _firstPerson.RangeYaw * 0.5f;
|
||||
float deltaYaw = Mathf.DeltaAngle(_firstPerson.ReferenceYaw, _state.Yaw);
|
||||
deltaYaw = Mathf.Clamp(deltaYaw, -halfRange, halfRange);
|
||||
_state.Yaw = _firstPerson.ReferenceYaw + deltaYaw;
|
||||
|
||||
_state.Pitch = Mathf.Clamp(_state.Pitch + mouseY, _firstPerson.MinPitch, _firstPerson.MaxPitch);
|
||||
}
|
||||
|
||||
if (State.Driver)
|
||||
State.Driver.ApplyLookInfluence(State.Yaw, State.Pitch, Time.deltaTime, out State.Yaw, out State.Pitch);
|
||||
if (_state.Driver)
|
||||
_state.Driver.ApplyLookInfluence(_state.Yaw, _state.Pitch, Time.deltaTime, out _state.Yaw, out _state.Pitch);
|
||||
|
||||
Quaternion YawRot = Quaternion.Euler(0, State.Yaw, 0);
|
||||
Quaternion PitchRot = Quaternion.Euler(State.Pitch, 0, 0);
|
||||
Quaternion YawRot = Quaternion.Euler(0, _state.Yaw, 0);
|
||||
Quaternion PitchRot = Quaternion.Euler(_state.Pitch, 0, 0);
|
||||
|
||||
transform.rotation = YawRot;
|
||||
cam.transform.localRotation = PitchRot;
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace OctoCore.Components
|
||||
[Range(.1f, 3)] public float LookAtSmooth = 1;
|
||||
[Range(0, 1)] public float LookAtPoint = .5f;
|
||||
public AnimationCurve DriveCurve = AnimationCurve.EaseInOut(0, 0, 1 , 1);
|
||||
public AnimationCurve LookCurve = AnimationCurve.EaseInOut(0, 0, 1 , 1);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
@@ -109,7 +110,7 @@ namespace OctoCore.Components
|
||||
|
||||
public void ApplyMoveInfluence(Vector3 inMove, float delta, out Vector3 outMove)
|
||||
{
|
||||
if (!OctoPlayer.Instance || !OctoPlayer.Instance._FirstPerson.Camera)
|
||||
if (!OctoPlayer.Instance || !OctoPlayer.Instance._FirstPerson.Camera || !_references.Target)
|
||||
{
|
||||
outMove = inMove;
|
||||
return;
|
||||
@@ -140,7 +141,7 @@ namespace OctoCore.Components
|
||||
|
||||
public void ApplyLookInfluence(float inYaw, float inPitch, float deltaTime, out float outYaw, out float outPitch)
|
||||
{
|
||||
if (!OctoPlayer.Instance || !OctoPlayer.Instance._FirstPerson.Camera)
|
||||
if (!OctoPlayer.Instance || !OctoPlayer.Instance._FirstPerson.Camera || !_references.LookAt)
|
||||
{
|
||||
outYaw = inYaw;
|
||||
outPitch = inPitch;
|
||||
@@ -158,7 +159,7 @@ namespace OctoCore.Components
|
||||
float lookAtPitch = Mathf.Asin(-lookAt.y) * Mathf.Rad2Deg;
|
||||
|
||||
_state.LookInfluence = Mathf.InverseLerp(_settings.LookAtPoint, 1, _state.MoveInfluence) * _settings.LookAtStrength;
|
||||
float lookInfluence = _settings.DriveCurve.Evaluate(_state.LookInfluence);
|
||||
float lookInfluence = _settings.LookCurve.Evaluate(_state.LookInfluence);
|
||||
|
||||
float t = deltaTime * _settings.LookAtSmooth;
|
||||
_state.YawRange = Mathf.Lerp(_state.YawRange, Mathf.Lerp(180, 0, lookInfluence), t);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using OctoCore.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OctoCore
|
||||
{
|
||||
public class OctoPlayerSpeedArea : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Settings
|
||||
{
|
||||
public float MinRadius = 1;
|
||||
public float MaxRadius = 4;
|
||||
|
||||
[Space(10)]
|
||||
|
||||
public float MinSpeedMultiplier = 0;
|
||||
public float MaxSpeedMultiplier = 1;
|
||||
|
||||
[Space(10)]
|
||||
|
||||
public AnimationCurve SpeedCurve = AnimationCurve.EaseInOut(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
[SerializeField] private Settings _settings;
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
UnityEditor.Handles.color = Color.cyan;
|
||||
UnityEditor.Handles.matrix = transform.localToWorldMatrix;
|
||||
|
||||
UnityEditor.Handles.DrawWireDisc(Vector3.zero, Vector3.up, _settings.MinRadius);
|
||||
UnityEditor.Handles.DrawWireDisc(Vector3.zero, Vector3.up, _settings.MaxRadius);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!OctoPlayer.Instance)
|
||||
return;
|
||||
|
||||
float dist = Vector3.Distance(transform.position, OctoPlayer.Instance.transform.position);
|
||||
|
||||
if (dist < _settings.MaxRadius)
|
||||
{
|
||||
float t = Mathf.InverseLerp(_settings.MinRadius, _settings.MaxRadius, dist);
|
||||
|
||||
float speedMultiplier = Mathf.Lerp(_settings.MinSpeedMultiplier, _settings.MaxSpeedMultiplier, t);
|
||||
|
||||
OctoPlayer.Instance.SetSppedMultiplier(speedMultiplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 516425b0868f3994c832b62ccc7be87a
|
||||
Reference in New Issue
Block a user