Merge branch 'master' of http://10.176.48.250:3000/scove/HALLUCINATE
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"version": 1,
|
||||
"name": "InputSystem_Actions",
|
||||
"maps": [
|
||||
{
|
||||
@@ -27,7 +28,7 @@
|
||||
"name": "Attack",
|
||||
"type": "Button",
|
||||
"id": "6c2ab1b8-8984-453a-af3d-a3c78ae1679a",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -63,7 +64,7 @@
|
||||
"name": "Previous",
|
||||
"type": "Button",
|
||||
"id": "2776c80d-3c14-4091-8c56-d04ced07a2b0",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -72,7 +73,7 @@
|
||||
"name": "Next",
|
||||
"type": "Button",
|
||||
"id": "b7230bb6-fc9b-4f52-8b25-f5e19cb2c2ba",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -81,7 +82,25 @@
|
||||
"name": "Sprint",
|
||||
"type": "Button",
|
||||
"id": "641cd816-40e6-41b4-8c3d-04687c349290",
|
||||
"expectedControlType": "Button",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Scroll",
|
||||
"type": "Value",
|
||||
"id": "1702ffae-5ad3-4532-9855-bf7e2a8ae749",
|
||||
"expectedControlType": "Vector2",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
},
|
||||
{
|
||||
"name": "ToggleView",
|
||||
"type": "Button",
|
||||
"id": "7e8b9416-0a2d-4652-98d8-e7368560ede9",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
@@ -319,6 +338,17 @@
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "c1c5f1be-b30c-4565-a190-774554559b8f",
|
||||
"path": "<Keyboard>/e",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Next",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "cbac6039-9c09-46a1-b5f2-4e5124ccb5ed",
|
||||
@@ -407,6 +437,17 @@
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f6175381-88f9-4a4c-b99f-ca84606ad42d",
|
||||
"path": "<Keyboard>/q",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Previous",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "1534dc16-a6aa-499d-9c3a-22b47347b52a",
|
||||
@@ -472,6 +513,39 @@
|
||||
"action": "Crouch",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "530195d8-9983-48c9-b5cf-305ee78dd292",
|
||||
"path": "<Mouse>/scroll",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Scroll",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f365517f-5a04-4d18-afa0-369ab80e0c54",
|
||||
"path": "<Keyboard>/f2",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "ToggleView",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "048282c5-5a5b-4ab2-9777-a20889af4532",
|
||||
"path": "<Gamepad>/buttonEast",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "ToggleView",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 052faaac586de48259a63d0c4782560b
|
||||
guid: ac73bbdc8e64ac34c9525df400c1534f
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
|
||||
@@ -152,40 +152,48 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.CameraController
|
||||
inputReader: {fileID: 0}
|
||||
followTarget: {fileID: 0}
|
||||
distance: 5
|
||||
minDistance: 2
|
||||
maxDistance: 15
|
||||
zoomSensitivity: 10
|
||||
sensitivity: 20
|
||||
collisionLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 192
|
||||
cameraRadius: 0.2
|
||||
positionSmoothTime: 0.08
|
||||
rotationSmoothTime: 10
|
||||
useAutoRotation: 1
|
||||
autoRotateDelay: 2.5
|
||||
autoRotateSpeed: 2
|
||||
useTransparency: 1
|
||||
transparencyLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
fadeAlpha: 0.3
|
||||
useDynamicFOV: 1
|
||||
baseFOV: 60
|
||||
sprintFOV: 70
|
||||
fovSmoothTime: 5
|
||||
useCharacterFading: 1
|
||||
minVisibleDistance: 1.2
|
||||
fullyHiddenDistance: 0.6
|
||||
characterRenderers:
|
||||
- {fileID: 0}
|
||||
useSideBias: 1
|
||||
horizontalBiasAmount: 0.5
|
||||
biasSmoothTime: 3
|
||||
useShake: 1
|
||||
minVerticalAngle: -45
|
||||
maxVerticalAngle: 45
|
||||
framingOffset: {x: 0.5, y: 1.5}
|
||||
invertX: 0
|
||||
invertY: 1
|
||||
rotationHandler:
|
||||
sensitivity: 10
|
||||
minVerticalAngle: -45
|
||||
maxVerticalAngle: 45
|
||||
invertX: 0
|
||||
invertY: 0
|
||||
useAutoRotation: 1
|
||||
autoRotateDelay: 2.5
|
||||
autoRotateSpeed: 2
|
||||
zoomHandler:
|
||||
distance: 20
|
||||
minDistance: 1
|
||||
maxDistance: 20
|
||||
zoomSensitivity: 10
|
||||
collisionHandler:
|
||||
collisionLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 192
|
||||
cameraRadius: 0.2
|
||||
occlusionTransparency:
|
||||
useTransparency: 1
|
||||
transparencyLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
fadeAlpha: 0.3
|
||||
dynamicFOV:
|
||||
useDynamicFOV: 1
|
||||
baseFOV: 60
|
||||
sprintFOV: 70
|
||||
fovSmoothTime: 5
|
||||
characterFading:
|
||||
useCharacterFading: 1
|
||||
minVisibleDistance: 1.2
|
||||
fullyHiddenDistance: 0.6
|
||||
characterRenderers:
|
||||
- {fileID: 0}
|
||||
sideBias:
|
||||
useSideBias: 1
|
||||
horizontalBiasAmount: 0.5
|
||||
biasSmoothTime: 3
|
||||
shakeManager:
|
||||
useShake: 1
|
||||
|
||||
@@ -18,7 +18,6 @@ GameObject:
|
||||
- component: {fileID: 3043298118541876184}
|
||||
- component: {fileID: 3866929919288054183}
|
||||
- component: {fileID: 5773292363125757170}
|
||||
- component: {fileID: 6232027636359170013}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@@ -80,13 +79,13 @@ CharacterController:
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Height: 1.8
|
||||
m_Radius: 0.2
|
||||
m_Height: 1.7584704
|
||||
m_Radius: 0.19215722
|
||||
m_SlopeLimit: 45
|
||||
m_StepOffset: 0.3
|
||||
m_SkinWidth: 0.08
|
||||
m_StepOffset: 0.26377058
|
||||
m_SkinWidth: 0.019215723
|
||||
m_MinMoveDistance: 0.001
|
||||
m_Center: {x: 0, y: 0.9, z: 0.1}
|
||||
m_Center: {x: 0, y: 0.8984509, z: 0.05}
|
||||
--- !u!95 &9098752589608501196
|
||||
Animator:
|
||||
serializedVersion: 7
|
||||
@@ -133,7 +132,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.PlayerInput
|
||||
m_Actions: {fileID: -944628639613478452, guid: 052faaac586de48259a63d0c4782560b, type: 3}
|
||||
m_Actions: {fileID: -944628639613478452, guid: ac73bbdc8e64ac34c9525df400c1534f, type: 3}
|
||||
m_NotificationBehavior: 2
|
||||
m_UIInputModule: {fileID: 0}
|
||||
m_DeviceLostEvent:
|
||||
@@ -180,13 +179,13 @@ MonoBehaviour:
|
||||
m_ActionName: 'Player/Look[/Mouse/delta]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1054594849095937263}
|
||||
m_TargetAssemblyTypeName: UnityEngine.GameObject, UnityEngine
|
||||
m_MethodName:
|
||||
m_Mode: 1
|
||||
- m_Target: {fileID: 5600577104145922999}
|
||||
m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
m_MethodName: OnAttack
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName:
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
@@ -196,13 +195,13 @@ MonoBehaviour:
|
||||
m_ActionName: 'Player/Attack[/Mouse/leftButton,/Keyboard/enter]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1054594849095937263}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName:
|
||||
m_Mode: 1
|
||||
- m_Target: {fileID: 5600577104145922999}
|
||||
m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
m_MethodName: OnInteract
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName:
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
@@ -244,13 +243,13 @@ MonoBehaviour:
|
||||
m_ActionName: 'Player/Jump[/Keyboard/space]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1054594849095937263}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName:
|
||||
m_Mode: 1
|
||||
- m_Target: {fileID: 5600577104145922999}
|
||||
m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
m_MethodName: OnPrevious
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName:
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
@@ -260,13 +259,13 @@ MonoBehaviour:
|
||||
m_ActionName: 'Player/Previous[/Keyboard/1]'
|
||||
- m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1054594849095937263}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName:
|
||||
m_Mode: 1
|
||||
- m_Target: {fileID: 5600577104145922999}
|
||||
m_TargetAssemblyTypeName: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
m_MethodName: OnNext
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName:
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
@@ -393,7 +392,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1054594849095937263}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e16a6690e589f0449ad89a6bf508ab62, type: 3}
|
||||
m_Name:
|
||||
@@ -410,7 +409,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1054594849095937263}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1630760c9d97a5f4eb1bc179549c95cd, type: 3}
|
||||
m_Name:
|
||||
@@ -431,48 +430,53 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1054594849095937263}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 271dd39a46bad974485107bb1a070e0a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.SukunaDomainController
|
||||
playerStateMachine: {fileID: 0}
|
||||
playerStateMachine: {fileID: 830356296960548640}
|
||||
slashPrefab: {fileID: 7424378359907903745, guid: 80f98b444eac25541afe9e9081c8303a, type: 3}
|
||||
shrinePrefab: {fileID: 5712645696331672719, guid: b0b71c635e9971346ae9ab6b7ecdd65d, type: 3}
|
||||
domainVolumeProfile: {fileID: 0}
|
||||
domainVolumeProfile: {fileID: 11400000, guid: 837c34edbcc0ece44ae8c54e25ec20de, type: 2}
|
||||
cinematicCameraPoint: {fileID: 0}
|
||||
domainRadius: 15
|
||||
domainRadius: 30
|
||||
domainDuration: 10
|
||||
slashRate: 15
|
||||
shrineRiseHeight: 4
|
||||
slashRate: 100
|
||||
shrineRiseHeight: 5
|
||||
shrineFloorOffset: 0.5
|
||||
camMoveSpeed: 4
|
||||
--- !u!114 &6232027636359170013
|
||||
MonoBehaviour:
|
||||
--- !u!1 &3751838835891881608
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1054594849095937263}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8958fecc82ae04c7d9128101addbdc3b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: WaveHarmonic.Crest::WaveHarmonic.Crest.SphereWaterInteraction
|
||||
_Version: 0
|
||||
_Radius: 0.8
|
||||
_Weight: 1
|
||||
_WeightVerticalMultiplier: 0.5
|
||||
_InnerSphereMultiplier: 1.55
|
||||
_InnerSphereOffset: 0.109
|
||||
_VelocityOffset: 0.04
|
||||
_CompensateForWaveMotion: 0.45
|
||||
_BoostLargeWaves: 0
|
||||
_TeleportSpeed: 500
|
||||
_WarnOnTeleport: 0
|
||||
_MaximumSpeed: 100
|
||||
_WarnOnSpeedClamp: 0
|
||||
_DebugSubsteps: 1
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5188652905305800431}
|
||||
m_Layer: 0
|
||||
m_Name: FPV Camera
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5188652905305800431
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3751838835891881608}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7173064969670908494}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &4262004705141875331
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -772,7 +776,7 @@ PrefabInstance:
|
||||
- target: {fileID: 2775862123970177323, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 2100000, guid: 0060976ac2b2a48498435dd6d13f0b27, type: 2}
|
||||
objectReference: {fileID: 3297912226980038121, guid: 8290c8e8479e3b744b22042adbe32801, type: 3}
|
||||
- target: {fileID: 2775862123970177323, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
propertyPath: 'm_Materials.Array.data[1]'
|
||||
value:
|
||||
@@ -783,7 +787,10 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: -3765236089850875182, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 5188652905305800431}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
--- !u!4 &3440275474486398839 stripped
|
||||
@@ -791,3 +798,8 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
m_PrefabInstance: {fileID: 2897196837322451100}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &7173064969670908494 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: -3765236089850875182, guid: 5847774ba45dc754598435b50d4a0247, type: 3}
|
||||
m_PrefabInstance: {fileID: 2897196837322451100}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
||||
@@ -411,7 +411,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: c6f1ec2975124834fbfdb5437314d9df, type: 2}
|
||||
- {fileID: 2100000, guid: b0a84576fc378a24cbb3bfc7be45a02e, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -588,7 +588,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: f78dd419a717d2744a4d18615c4b199c, type: 2}
|
||||
- {fileID: 2100000, guid: e2e2684e969402049b87d7f81417c603, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@@ -642,7 +642,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: f78dd419a717d2744a4d18615c4b199c, type: 2}
|
||||
- {fileID: 2100000, guid: e2e2684e969402049b87d7f81417c603, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -689,6 +689,11 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &1631120432 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 5188652905305800431, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!4 &1732205146 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8004958684693924044, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
@@ -759,7 +764,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 29d8aeef71b97864a9ad6317a4738f26, type: 2}
|
||||
- {fileID: 2100000, guid: d7e691e02b41b9a47b417cc138d6f1bc, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -806,17 +811,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1965226596 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 830356296960548640, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
m_PrefabInstance: {fileID: 8240317044381527393}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 848ad6fdeb60b254497391392419b063, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::OnlyScove.Scripts.PlayerStateMachine
|
||||
--- !u!1 &2101138892
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -961,6 +955,14 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Main Camera
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2771692228748849855, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: m_Layer
|
||||
value: 8
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: fpvTarget
|
||||
value:
|
||||
objectReference: {fileID: 1631120432}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: inputReader
|
||||
value:
|
||||
@@ -977,6 +979,10 @@ PrefabInstance:
|
||||
propertyPath: 'characterRenderers.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 166789747}
|
||||
- target: {fileID: 3657229949309460766, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: 'characterFading.characterRenderers.Array.data[0]'
|
||||
value:
|
||||
objectReference: {fileID: 166789747}
|
||||
- target: {fileID: 8391577239842762580, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
|
||||
propertyPath: m_RenderPostProcessing
|
||||
value: 1
|
||||
@@ -994,6 +1000,10 @@ PrefabInstance:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 830356296960548640, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: <InteractionMask>k__BackingField.m_Bits
|
||||
value: 512
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player
|
||||
@@ -1015,83 +1025,43 @@ PrefabInstance:
|
||||
value:
|
||||
objectReference: {fileID: 442028704}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
propertyPath: m_ActionEvents.Array.size
|
||||
value: 21
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_ActionId
|
||||
value: 7e8b9416-0a2d-4652-98d8-e7368560ede9
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_ActionName
|
||||
value: 'Player/Change View[/Keyboard/f2]'
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.size
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Mode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 216247156}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnAttack
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_CallState
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnInteract
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnToggleView
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnPrevious
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: OnNext
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: OnlyScove.Scripts.InputReader, Assembly-CSharp
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[2].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[3].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[6].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3010251870038942475, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_ActionEvents.Array.data[7].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
propertyPath: m_ActionEvents.Array.data[20].m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
|
||||
value: UnityEngine.Object, UnityEngine
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
@@ -1146,58 +1116,10 @@ PrefabInstance:
|
||||
propertyPath: autoDetectOnStart
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: slashRate
|
||||
value: 100
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: domainRadius
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: shrineRiseHeight
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: playerStateMachine
|
||||
value:
|
||||
objectReference: {fileID: 1965226596}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: domainVolumeProfile
|
||||
value:
|
||||
objectReference: {fileID: 11400000, guid: 837c34edbcc0ece44ae8c54e25ec20de, type: 2}
|
||||
- target: {fileID: 5773292363125757170, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: cinematicCameraPoint
|
||||
value:
|
||||
objectReference: {fileID: 2101138893}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Height
|
||||
value: 1.7584704
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Radius
|
||||
value: 0.19215722
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Center.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Center.y
|
||||
value: 0.8984509
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_Center.z
|
||||
value: 0.05
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_SkinWidth
|
||||
value: 0.019215723
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8915611492738107882, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
propertyPath: m_StepOffset
|
||||
value: 0.26377058
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents:
|
||||
- {fileID: 6587788942094262397, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
- {fileID: 5294322338071205561, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
# PROJECT CONTEXT & ARCHITECTURE
|
||||
- Engine: Unity 6.3
|
||||
- Genre: 3D Third-Person Action Game (TPS)
|
||||
- Input: Unity New Input System (using InputReader script)
|
||||
- Pattern: Hierarchical State Machine (HSM) / State Pattern
|
||||
- Coding Rules: Strictly English for all variables, methods, classes, and comments. Use CharacterController for movement. Handle rotation using Quaternion.Slerp.
|
||||
|
||||
# 1. INPUT READER (InputReader.cs)
|
||||
Inherits: MonoBehaviour
|
||||
Properties:
|
||||
- Vector2 MoveInput (from WASD/Left Stick)
|
||||
- bool IsSprintHeld (from Left Shift - continuous hold)
|
||||
Events (Actions):
|
||||
- event Action OnJumpEvent (Space bar pressed)
|
||||
- event Action OnDodgeEvent (Right Mouse Button - RMB pressed)
|
||||
- event Action OnCrouchEvent (C key pressed)
|
||||
|
||||
# 2. ANIMATOR SETUP REQUIREMENTS
|
||||
Parameters:
|
||||
- "Speed" (Float): Grounded movement (0.0 = Idle, 0.5 = Walk, 1.0 = Run).
|
||||
- "IsCrouching" (Bool): Toggle crouch mode.
|
||||
- "CrouchSpeed" (Float): Crouch movement (0.0 = Idle, 0.5 = Sneak, 1.0 = Walk).
|
||||
- Triggers: "Dash", "Jump", "Fall", "AirDash", "Thrust", "Dodge".
|
||||
|
||||
# 3. STATE MACHINE CORE (PlayerStateMachine.cs)
|
||||
Inherits: MonoBehaviour
|
||||
RequireComponents: CharacterController, InputReader, Animator
|
||||
Variables:
|
||||
- float WalkSpeed = 3f, RunSpeed = 6f, DashForce = 10f, SneakSpeed = 1.5f
|
||||
- float JumpForce = 5f, Gravity = -9.81f, ThrustDownwardForce = -20f
|
||||
- float VelocityY (tracks vertical speed)
|
||||
- PlayerBaseState currentState
|
||||
Methods:
|
||||
- SwitchState(PlayerBaseState newState): calls currentState.Exit(), updates state, calls currentState.Enter().
|
||||
- Update(): calls currentState.Tick(Time.deltaTime).
|
||||
- FixedUpdate(): calls currentState.PhysicsTick(Time.fixedDeltaTime).
|
||||
|
||||
# 4. BASE STATE (PlayerBaseState.cs)
|
||||
Abstract class. Constructor takes (PlayerStateMachine stateMachine).
|
||||
Abstract Methods: Enter(), Tick(float deltaTime), PhysicsTick(float fixedDeltaTime), Exit().
|
||||
|
||||
# 5. DETAILED STATE LOGICS
|
||||
|
||||
## PlayerIdleState
|
||||
- Enter: Subscribe to OnJumpEvent, OnDodgeEvent, OnCrouchEvent.
|
||||
- Tick: SmoothDamp "Speed" to 0.0. If MoveInput != Vector2.zero -> SwitchState(PlayerMoveState).
|
||||
- Exit: Unsubscribe events.
|
||||
|
||||
## PlayerMoveState
|
||||
- Enter: Subscribe to events (Jump, Dodge, Crouch).
|
||||
- Tick:
|
||||
- If MoveInput == Vector2.zero -> SwitchState(PlayerIdleState).
|
||||
- If IsSprintHeld == true -> SwitchState(PlayerDashState).
|
||||
- Move using CharacterController (MoveInput * WalkSpeed).
|
||||
- Slerp rotation towards MoveInput direction.
|
||||
- SmoothDamp "Speed" to 0.5.
|
||||
- Exit: Unsubscribe events.
|
||||
|
||||
## PlayerDashState
|
||||
- Variables: timer = 0.25s, dashDirection (Vector3).
|
||||
- Enter: Set dashDirection to MoveInput (or transform.forward if 0). Snap rotation to dashDirection. SetTrigger("Dash").
|
||||
- Tick:
|
||||
- Move at DashForce along dashDirection (no gravity applied).
|
||||
- timer -= deltaTime.
|
||||
- If timer <= 0:
|
||||
- If IsSprintHeld AND MoveInput != 0 -> SwitchState(PlayerRunState).
|
||||
- If MoveInput != 0 -> SwitchState(PlayerMoveState).
|
||||
- Else -> SwitchState(PlayerIdleState).
|
||||
|
||||
## PlayerRunState
|
||||
- Enter: Subscribe to events (Jump, Dodge, Crouch).
|
||||
- Tick:
|
||||
- If MoveInput == 0 -> SwitchState(PlayerIdleState).
|
||||
- If IsSprintHeld == false -> SwitchState(PlayerMoveState).
|
||||
- Move using CharacterController (MoveInput * RunSpeed). Slerp rotation.
|
||||
- SmoothDamp "Speed" to 1.0.
|
||||
- Exit: Unsubscribe events.
|
||||
|
||||
## PlayerJumpState
|
||||
- Enter: SetTrigger("Jump"). VelocityY = JumpForce.
|
||||
- Tick:
|
||||
- Apply Gravity (VelocityY += Gravity * deltaTime).
|
||||
- Apply horizontal Air Control (MoveInput * WalkSpeed).
|
||||
- Move using CharacterController (Horizontal + Vertical).
|
||||
- If VelocityY <= 0 -> SwitchState(PlayerFallState).
|
||||
|
||||
## PlayerFallState
|
||||
- Enter: SetTrigger("Fall"). Subscribe to OnDodgeEvent (maps to Thrust here).
|
||||
- Tick:
|
||||
- Apply Gravity. Apply horizontal Air Control. Move via Controller.
|
||||
- If IsSprintHeld -> SwitchState(PlayerAirDashState).
|
||||
- If isGrounded -> Set VelocityY = -2f. SwitchState(Idle or Move based on input).
|
||||
- Thrust Event Trigger: SwitchState(PlayerThrustState).
|
||||
- Exit: Unsubscribe OnDodgeEvent.
|
||||
|
||||
## PlayerAirDashState
|
||||
- Variables: timer = 0.2s, dashDir.
|
||||
- Enter: SetTrigger("AirDash"). VelocityY = 0f. Set dashDir based on MoveInput.
|
||||
- Tick:
|
||||
- Move horizontally at DashForce (VelocityY stays 0).
|
||||
- timer -= deltaTime. If timer <= 0 -> SwitchState(PlayerFallState).
|
||||
|
||||
## PlayerThrustState
|
||||
- Enter: SetTrigger("Thrust"). VelocityY = ThrustDownwardForce.
|
||||
- Tick:
|
||||
- VelocityY += (Gravity * 2) * deltaTime. Move purely downwards (no horizontal).
|
||||
- If isGrounded -> Set VelocityY = -2f. SwitchState(PlayerIdleState).
|
||||
|
||||
## PlayerCrouchState
|
||||
- Enter: SetBool("IsCrouching", true). Subscribe to OnCrouchEvent (Toggle), OnDodgeEvent.
|
||||
- Tick:
|
||||
- If MoveInput == 0: "CrouchSpeed" = 0.0.
|
||||
- If MoveInput != 0 AND IsSprintHeld: Move at SneakSpeed. "CrouchSpeed" = 0.5.
|
||||
- If MoveInput != 0 AND !IsSprintHeld: Move at WalkSpeed. "CrouchSpeed" = 1.0.
|
||||
- Apply Movement and Slerp rotation.
|
||||
- Toggle Event Trigger (C key): SwitchState(Idle or Move).
|
||||
- Dodge Event Trigger (LMB): SwitchState(PlayerDodgeState).
|
||||
- Exit: SetBool("IsCrouching", false). Unsubscribe events.
|
||||
|
||||
## PlayerDodgeState
|
||||
- Variables: timer = 0.4s, dodgeDir.
|
||||
- Enter: SetTrigger("Dodge"). Set dodgeDir based on MoveInput (Left/Right/Back/Forward). Snap rotation.
|
||||
- Tick:
|
||||
- Move at (DashForce * 0.8) along dodgeDir.
|
||||
- timer -= deltaTime.
|
||||
- If timer <= 0 -> SwitchState(Idle or Move based on MoveInput).
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0237005d5b554958bc3a87b1cec34c9e
|
||||
timeCreated: 1773378307
|
||||
31
Assets/Scripts/Camera Controller/CameraCharacterFading.cs
Normal file
31
Assets/Scripts/Camera Controller/CameraCharacterFading.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraCharacterFading
|
||||
{
|
||||
[Header("Character Fading")]
|
||||
[SerializeField] private bool useCharacterFading = true;
|
||||
[SerializeField] private float minVisibleDistance = 1.2f;
|
||||
[SerializeField] private float fullyHiddenDistance = 0.6f;
|
||||
[SerializeField] private Renderer[] characterRenderers;
|
||||
|
||||
public void HandleCharacterFading(float currentDistance)
|
||||
{
|
||||
if (!useCharacterFading || characterRenderers == null || characterRenderers.Length == 0) return;
|
||||
|
||||
float alpha = Mathf.InverseLerp(fullyHiddenDistance, minVisibleDistance, currentDistance);
|
||||
|
||||
foreach (var renderer in characterRenderers)
|
||||
{
|
||||
if (renderer != null)
|
||||
{
|
||||
Color color = renderer.material.color;
|
||||
color.a = alpha;
|
||||
renderer.material.color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d5d8d2fa005cd34a92ee259df535130
|
||||
24
Assets/Scripts/Camera Controller/CameraCollisionHandler.cs
Normal file
24
Assets/Scripts/Camera Controller/CameraCollisionHandler.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraCollisionHandler
|
||||
{
|
||||
[Header("Collision Settings")]
|
||||
[SerializeField] private LayerMask collisionLayers;
|
||||
[SerializeField] private float cameraRadius = 0.2f;
|
||||
public float CheckCollision(Vector3 focusPosition, Quaternion currentRotation, float targetDistance, float minimumDistanceAllowed)
|
||||
{
|
||||
RaycastHit hit;
|
||||
Vector3 rayStart = focusPosition;
|
||||
Vector3 rayDirection = currentRotation * Vector3.back;
|
||||
|
||||
if (Physics.SphereCast(rayStart, cameraRadius, rayDirection, out hit, targetDistance, collisionLayers))
|
||||
{
|
||||
return Mathf.Max(minimumDistanceAllowed, hit.distance - 0.1f);
|
||||
}
|
||||
return targetDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57a506759df838e42b577ebdb542500b
|
||||
@@ -1,287 +1,215 @@
|
||||
using System;
|
||||
using System; // For Action event
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class CameraController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] InputReader inputReader; // Kéo thả Object chứa InputReader vào đây
|
||||
[SerializeField] Transform followTarget;
|
||||
[SerializeField] float distance = 5;
|
||||
[SerializeField] float minDistance = 2f;
|
||||
[SerializeField] float maxDistance = 15f;
|
||||
[SerializeField] float zoomSensitivity = 1f;
|
||||
[SerializeField] float sensitivity = 0.1f; // Độ nhạy (chỉnh trong Inspector)
|
||||
[SerializeField] LayerMask collisionLayers;
|
||||
[SerializeField] float cameraRadius = 0.2f;
|
||||
[SerializeField] float positionSmoothTime = 0.12f; // Độ trễ đuổi theo nhân vật
|
||||
[SerializeField] float rotationSmoothTime = 5f; // Tốc độ làm mượt vòng xoay chuột
|
||||
|
||||
[Header("Auto Rotation")]
|
||||
[SerializeField] bool useAutoRotation = true;
|
||||
[SerializeField] float autoRotateDelay = 2.5f; // Sau bao lâu không chạm chuột thì xoay
|
||||
[SerializeField] float autoRotateSpeed = 2f; // Tốc độ xoay về sau lưng
|
||||
|
||||
[Header("Occlusion Transparency")]
|
||||
[SerializeField] bool useTransparency = true;
|
||||
[SerializeField] LayerMask transparencyLayers;
|
||||
[SerializeField] float fadeAlpha = 0.3f; // Độ trong suốt (0 là biến mất, 1 là hiện rõ)
|
||||
|
||||
[Header("Dynamic FOV")]
|
||||
[SerializeField] bool useDynamicFOV = true;
|
||||
[SerializeField] float baseFOV = 60f;
|
||||
[SerializeField] float sprintFOV = 70f;
|
||||
[SerializeField] float fovSmoothTime = 5f;
|
||||
|
||||
[Header("Character Fading")]
|
||||
[SerializeField] bool useCharacterFading = true;
|
||||
[SerializeField] float minVisibleDistance = 1.2f; // Khoảng cách bắt đầu mờ
|
||||
[SerializeField] float fullyHiddenDistance = 0.6f; // Khoảng cách biến mất hẳn
|
||||
[SerializeField] Renderer[] characterRenderers; // Kéo các Mesh của nhân vật vào đây
|
||||
|
||||
[Header("Side Bias")]
|
||||
[SerializeField] bool useSideBias = true;
|
||||
[SerializeField] float horizontalBiasAmount = 0.5f; // Độ lệch sang trái/phải
|
||||
[SerializeField] float biasSmoothTime = 3f; // Tốc độ chuyển đổi độ lệch
|
||||
public enum CameraViewMode { ThirdPerson, FirstPerson }
|
||||
|
||||
[Header("Camera Shake")]
|
||||
[SerializeField] bool useShake = true;
|
||||
private float shakeIntensity = 0f;
|
||||
private float shakeDuration = 0f;
|
||||
private float shakeTimer = 0f;
|
||||
private Vector3 shakeOffset;
|
||||
|
||||
[SerializeField] float minVerticalAngle = -45f;
|
||||
[SerializeField] float maxVerticalAngle = 45f;
|
||||
[SerializeField] InputReader inputReader;
|
||||
[SerializeField] Transform followTarget; // Player's root for TPV
|
||||
[SerializeField] float positionSmoothTime = 0.12f;
|
||||
[SerializeField] float rotationSmoothTime = 5f;
|
||||
[SerializeField] Vector2 framingOffset;
|
||||
[SerializeField] private bool invertX;
|
||||
[SerializeField] private bool invertY;
|
||||
|
||||
private float rotationX;
|
||||
private float rotationY;
|
||||
|
||||
private float invertXVal;
|
||||
private float invertYVal;
|
||||
|
||||
private float lastInputTime;
|
||||
private Vector3 currentVelocity;
|
||||
private Quaternion currentRotation;
|
||||
[Header("Components")]
|
||||
[SerializeField] private CameraRotationHandler rotationHandler = new CameraRotationHandler();
|
||||
[SerializeField] private CameraZoomHandler zoomHandler = new CameraZoomHandler();
|
||||
[SerializeField] private CameraCollisionHandler collisionHandler = new CameraCollisionHandler();
|
||||
[SerializeField] private CameraOcclusionTransparency occlusionTransparency = new CameraOcclusionTransparency();
|
||||
[SerializeField] private CameraDynamicFOV dynamicFOV = new CameraDynamicFOV();
|
||||
[SerializeField] private CameraCharacterFading characterFading = new CameraCharacterFading();
|
||||
[SerializeField] private CameraSideBias sideBias = new CameraSideBias();
|
||||
[SerializeField] private CameraShakeManager shakeManager = new CameraShakeManager();
|
||||
|
||||
private Camera cam;
|
||||
private Renderer lastFadedRenderer;
|
||||
private Color originalColor;
|
||||
|
||||
private float currentSideBias;
|
||||
[Header("First Person View Settings")]
|
||||
[SerializeField] Transform fpvTarget; // Specific transform on the player (e.g., eye level)
|
||||
[SerializeField] float fpvPositionSmoothTime = 0.05f;
|
||||
[SerializeField] float fpvRotationSmoothTime = 20f;
|
||||
[SerializeField] float fpvFOV = 80f;
|
||||
[SerializeField] float transitionDuration = 0.3f;
|
||||
[SerializeField] float tpvBaseFOV = 60f; // Existing base FOV for TPV
|
||||
|
||||
private Vector3 _currentVelocity;
|
||||
private Camera _cam;
|
||||
private CameraViewMode _currentViewMode = CameraViewMode.ThirdPerson;
|
||||
private CameraViewMode _targetViewMode = CameraViewMode.ThirdPerson;
|
||||
private float _transitionTimer = 0f;
|
||||
private bool _inTransition = false;
|
||||
|
||||
public CameraViewMode CurrentViewMode => _currentViewMode;
|
||||
|
||||
// Properties to get current smoothing values based on view mode
|
||||
private float CurrentPositionSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvPositionSmoothTime : positionSmoothTime;
|
||||
private float CurrentRotationSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvRotationSmoothTime : rotationSmoothTime;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleViewEvent += ToggleCameraView;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleViewEvent -= ToggleCameraView;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cam = GetComponent<Camera>();
|
||||
_cam = GetComponent<Camera>();
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
|
||||
// Khởi tạo vòng xoay hiện tại
|
||||
rotationX = transform.eulerAngles.x;
|
||||
rotationY = transform.eulerAngles.y;
|
||||
currentRotation = transform.rotation;
|
||||
lastInputTime = Time.time;
|
||||
|
||||
rotationHandler.Initialize(transform);
|
||||
dynamicFOV.Initialize(tpvBaseFOV: tpvBaseFOV, fpvFOV: fpvFOV); // Pass TPV and FPV base FOVs
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
HandleViewTransition();
|
||||
|
||||
if (inputReader != null)
|
||||
{
|
||||
// Kiểm tra xem có input xoay chuột không
|
||||
if (inputReader.LookInput.magnitude > 0.01f)
|
||||
{
|
||||
lastInputTime = Time.time;
|
||||
}
|
||||
// Input-related updates are handled differently based on view mode
|
||||
rotationHandler.HandleRotation(inputReader, followTarget, CurrentRotationSmoothTime, _currentViewMode);
|
||||
|
||||
invertXVal = (invertX) ? -1 : 1;
|
||||
invertYVal = (invertY) ? -1 : 1;
|
||||
|
||||
rotationX -= inputReader.LookInput.y * invertYVal * sensitivity * Time.deltaTime;
|
||||
rotationX = Mathf.Clamp(rotationX, minVerticalAngle, maxVerticalAngle);
|
||||
|
||||
rotationY += inputReader.LookInput.x * invertXVal * sensitivity * Time.deltaTime;
|
||||
|
||||
// Logic Side Bias (Lệch khung hình khi di chuyển)
|
||||
if (useSideBias)
|
||||
if (_currentViewMode == CameraViewMode.ThirdPerson)
|
||||
{
|
||||
float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount;
|
||||
currentSideBias = Mathf.Lerp(currentSideBias, targetBias, biasSmoothTime * Time.deltaTime);
|
||||
zoomHandler.HandleZoom(inputReader);
|
||||
sideBias.HandleSideBias(inputReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSideBias = 0;
|
||||
// Disable side bias and zoom in FPV
|
||||
sideBias.HandleSideBias(null); // Pass null to effectively disable
|
||||
zoomHandler.HandleZoom(null); // Pass null to effectively disable
|
||||
}
|
||||
dynamicFOV.HandleDynamicFOV(_cam, inputReader, _currentViewMode);
|
||||
}
|
||||
|
||||
// Logic Tự động xoay sau lưng (Auto-Correction)
|
||||
if (useAutoRotation && Time.time - lastInputTime > autoRotateDelay)
|
||||
Vector3 focusPosition;
|
||||
float targetDistance;
|
||||
|
||||
if (_currentViewMode == CameraViewMode.ThirdPerson)
|
||||
{
|
||||
// TPV specific calculations
|
||||
transform.rotation = rotationHandler.CurrentRotation; // Set camera rotation from handler
|
||||
focusPosition = followTarget.position + rotationHandler.CurrentRotation * new Vector3(framingOffset.x + sideBias.CurrentSideBias, framingOffset.y, 0);
|
||||
targetDistance = collisionHandler.CheckCollision(focusPosition, rotationHandler.CurrentRotation, zoomHandler.CurrentDistance, zoomHandler.MinDistance);
|
||||
characterFading.HandleCharacterFading(targetDistance);
|
||||
occlusionTransparency.HandleTransparency(transform, focusPosition);
|
||||
}
|
||||
else // FirstPerson
|
||||
{
|
||||
// FPV specific calculations
|
||||
// Player's horizontal rotation (body) follows mouse YAW
|
||||
if (followTarget != null)
|
||||
{
|
||||
// Chỉ xoay khi nhân vật đang di chuyển
|
||||
if (inputReader.MoveInput.magnitude > 0.1f)
|
||||
{
|
||||
// Lấy hướng nhân vật đang nhìn (Yaw)
|
||||
float targetYaw = followTarget.eulerAngles.y;
|
||||
// Dùng LerpAngle để xoay mượt mà về hướng đó
|
||||
rotationY = Mathf.LerpAngle(rotationY, targetYaw, autoRotateSpeed * Time.deltaTime);
|
||||
}
|
||||
followTarget.rotation = rotationHandler.PlanarRotation; // Sync body to camera yaw
|
||||
}
|
||||
|
||||
float scrollDelta = inputReader.ScrollInput.y;
|
||||
if (Mathf.Abs(scrollDelta) > 0.1f)
|
||||
if (fpvTarget != null)
|
||||
{
|
||||
distance -= scrollDelta * zoomSensitivity * Time.deltaTime;
|
||||
distance = Mathf.Clamp(distance, minDistance, maxDistance);
|
||||
fpvTarget.rotation = rotationHandler.CurrentRotation; // Sync head/eyes to full camera rotation
|
||||
}
|
||||
}
|
||||
|
||||
// Xoay chuột: Làm mượt bằng Slerp
|
||||
Quaternion targetRotation = Quaternion.Euler(rotationX, rotationY, 0f);
|
||||
currentRotation = Quaternion.Slerp(currentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
|
||||
|
||||
// Vị trí mục tiêu: Áp dụng offset + Side Bias
|
||||
Vector3 focusPosition = followTarget.position + currentRotation * new Vector3(framingOffset.x + currentSideBias, framingOffset.y, 0);
|
||||
|
||||
// Collision Logic (Dùng currentRotation đã được làm mượt)
|
||||
float targetDistance = distance;
|
||||
RaycastHit hit;
|
||||
Vector3 rayStart = focusPosition;
|
||||
Vector3 rayDirection = currentRotation * Vector3.back;
|
||||
transform.rotation = rotationHandler.CurrentRotation; // Set camera rotation from handler (which includes vertical)
|
||||
focusPosition = fpvTarget.position;
|
||||
targetDistance = 0; // FPV has no distance to player
|
||||
|
||||
if (Physics.SphereCast(rayStart, cameraRadius, rayDirection, out hit, distance, collisionLayers))
|
||||
{
|
||||
targetDistance = Mathf.Max(minDistance, hit.distance - 0.1f);
|
||||
// Disable TPV-specific effects
|
||||
characterFading.HandleCharacterFading(0); // Fully opaque character in FPV
|
||||
occlusionTransparency.HandleTransparency(transform, fpvTarget.position); // Can still have occlusion transparency for environment in FPV
|
||||
}
|
||||
|
||||
// Logic Làm mờ nhân vật (Character Fading)
|
||||
if (useCharacterFading && characterRenderers != null && characterRenderers.Length > 0)
|
||||
{
|
||||
HandleCharacterFading(targetDistance);
|
||||
}
|
||||
// Calculate target position using the currently set transform.rotation
|
||||
Vector3 targetPosition = focusPosition - transform.rotation * new Vector3(0, 0, targetDistance);
|
||||
// Handle camera shake
|
||||
shakeManager.HandleShake();
|
||||
|
||||
// Vị trí cuối cùng: Làm mượt bằng SmoothDamp để tạo độ trễ đuổi theo
|
||||
Vector3 targetPosition = focusPosition - currentRotation * new Vector3(0, 0, targetDistance);
|
||||
|
||||
// Xử lý Camera Shake
|
||||
if (useShake && shakeTimer > 0)
|
||||
{
|
||||
HandleShake();
|
||||
}
|
||||
else
|
||||
{
|
||||
shakeOffset = Vector3.zero;
|
||||
}
|
||||
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref currentVelocity, positionSmoothTime) + shakeOffset;
|
||||
transform.rotation = currentRotation;
|
||||
|
||||
// Logic Làm trong suốt vật cản (Occlusion Transparency)
|
||||
if (useTransparency)
|
||||
{
|
||||
HandleTransparency(focusPosition);
|
||||
}
|
||||
|
||||
// Logic FOV linh hoạt
|
||||
if (useDynamicFOV && cam != null)
|
||||
{
|
||||
HandleDynamicFOV();
|
||||
}
|
||||
// Apply final position and rotation
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, CurrentPositionSmoothTime) + shakeManager.ShakeOffset;
|
||||
}
|
||||
|
||||
private void HandleDynamicFOV()
|
||||
private void ToggleCameraView()
|
||||
{
|
||||
float targetFOV = baseFOV;
|
||||
if (_inTransition) return; // Prevent multiple toggles during transition
|
||||
|
||||
// Nếu đang di chuyển và nhấn giữ nút Sprint
|
||||
if (inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld)
|
||||
{
|
||||
targetFOV = sprintFOV;
|
||||
}
|
||||
|
||||
// Làm mượt quá trình thay đổi FOV
|
||||
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, fovSmoothTime * Time.deltaTime);
|
||||
_targetViewMode = (_currentViewMode == CameraViewMode.ThirdPerson) ? CameraViewMode.FirstPerson : CameraViewMode.ThirdPerson;
|
||||
Debug.Log($"[CameraController] Toggling view from {_currentViewMode} to {_targetViewMode}");
|
||||
_inTransition = true;
|
||||
_transitionTimer = 0f;
|
||||
}
|
||||
|
||||
private void HandleShake()
|
||||
private void HandleViewTransition()
|
||||
{
|
||||
shakeTimer -= Time.deltaTime;
|
||||
|
||||
// Cường độ rung giảm dần theo thời gian
|
||||
float currentIntensity = (shakeTimer / shakeDuration) * shakeIntensity;
|
||||
|
||||
// Dùng Perlin Noise để tạo rung động mượt mà
|
||||
float shakeX = (Mathf.PerlinNoise(Time.time * 25f, 0f) - 0.5f) * 2f;
|
||||
float shakeY = (Mathf.PerlinNoise(0f, Time.time * 25f) - 0.5f) * 2f;
|
||||
float shakeZ = (Mathf.PerlinNoise(Time.time * 25f, Time.time * 25f) - 0.5f) * 2f;
|
||||
if (!_inTransition) return;
|
||||
|
||||
shakeOffset = new Vector3(shakeX, shakeY, shakeZ) * currentIntensity;
|
||||
_transitionTimer += Time.deltaTime;
|
||||
float t = _transitionTimer / transitionDuration;
|
||||
t = Mathf.Clamp01(t); // Clamp t between 0 and 1
|
||||
|
||||
// Smoothly interpolate parameters during transition
|
||||
if (_currentViewMode == CameraViewMode.ThirdPerson && _targetViewMode == CameraViewMode.FirstPerson)
|
||||
{
|
||||
// TPV -> FPV transition
|
||||
// Interpolate FOV
|
||||
_cam.fieldOfView = Mathf.Lerp(dynamicFOV.CurrentTpvBaseFOV, fpvFOV, t);
|
||||
|
||||
// Rotate player body to match camera's intended horizontal look direction
|
||||
if (followTarget != null)
|
||||
{
|
||||
followTarget.rotation = Quaternion.Slerp(followTarget.rotation, rotationHandler.PlanarRotation, t);
|
||||
}
|
||||
|
||||
// Interpolate position and rotation
|
||||
transform.position = Vector3.Lerp(transform.position, fpvTarget.position, t);
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, fpvTarget.rotation, t);
|
||||
}
|
||||
else if (_currentViewMode == CameraViewMode.FirstPerson && _targetViewMode == CameraViewMode.ThirdPerson)
|
||||
{
|
||||
// FPV -> TPV transition
|
||||
// Interpolate FOV
|
||||
_cam.fieldOfView = Mathf.Lerp(fpvFOV, dynamicFOV.CurrentTpvBaseFOV, t);
|
||||
}
|
||||
|
||||
if (t >= 1f)
|
||||
{
|
||||
_currentViewMode = _targetViewMode;
|
||||
Debug.Log($"[CameraController] View transition complete. Current mode: {_currentViewMode}");
|
||||
_inTransition = false;
|
||||
|
||||
// Initialize rotation handler based on new view mode
|
||||
if (_currentViewMode == CameraViewMode.FirstPerson && fpvTarget != null)
|
||||
{
|
||||
rotationHandler.InitializeFPV(fpvTarget); // Initialize FPV rotation handler
|
||||
}
|
||||
else
|
||||
{
|
||||
rotationHandler.Initialize(transform); // Initialize TPV rotation handler
|
||||
}
|
||||
|
||||
// Ensure FOV is set correctly at the end of transition
|
||||
_cam.fieldOfView = (_currentViewMode == CameraViewMode.FirstPerson) ? fpvFOV : dynamicFOV.CurrentTpvBaseFOV;
|
||||
}
|
||||
}
|
||||
|
||||
public void Shake(float intensity, float duration)
|
||||
{
|
||||
shakeIntensity = intensity;
|
||||
shakeDuration = duration;
|
||||
shakeTimer = duration;
|
||||
shakeManager.Shake(intensity, duration);
|
||||
}
|
||||
|
||||
private void HandleCharacterFading(float currentDistance)
|
||||
public void TriggerFallImpactShake(float fallHeight)
|
||||
{
|
||||
// Tính độ mờ dựa trên khoảng cách
|
||||
float alpha = Mathf.InverseLerp(fullyHiddenDistance, minVisibleDistance, currentDistance);
|
||||
|
||||
foreach (var renderer in characterRenderers)
|
||||
{
|
||||
if (renderer != null)
|
||||
{
|
||||
Color color = renderer.material.color;
|
||||
color.a = alpha;
|
||||
renderer.material.color = color;
|
||||
}
|
||||
}
|
||||
shakeManager.TriggerFallImpactShake(fallHeight);
|
||||
}
|
||||
|
||||
private void HandleTransparency(Vector3 focusPosition)
|
||||
{
|
||||
Vector3 direction = focusPosition - transform.position;
|
||||
float distanceToPlayer = direction.magnitude;
|
||||
RaycastHit hit;
|
||||
|
||||
// Bắn một tia từ Camera đến Nhân vật
|
||||
if (Physics.Raycast(transform.position, direction.normalized, out hit, distanceToPlayer, transparencyLayers))
|
||||
{
|
||||
Renderer renderer = hit.collider.GetComponent<Renderer>();
|
||||
if (renderer != null && renderer != lastFadedRenderer)
|
||||
{
|
||||
// Nếu chạm vật mới, khôi phục vật cũ
|
||||
ResetLastRenderer();
|
||||
|
||||
// Lưu thông tin vật mới và làm mờ
|
||||
lastFadedRenderer = renderer;
|
||||
originalColor = renderer.material.color;
|
||||
Color fadedColor = originalColor;
|
||||
fadedColor.a = fadeAlpha;
|
||||
|
||||
// Lưu ý: Material cần hỗ trợ Transparency (Surface Type: Transparent trong URP)
|
||||
renderer.material.color = fadedColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nếu không chạm gì, khôi phục vật cũ
|
||||
ResetLastRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetLastRenderer()
|
||||
{
|
||||
if (lastFadedRenderer != null)
|
||||
{
|
||||
lastFadedRenderer.material.color = originalColor;
|
||||
lastFadedRenderer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Quaternion PlanarRotation => Quaternion.Euler(0f, rotationY, 0f);
|
||||
public Quaternion PlanarRotation => rotationHandler.PlanarRotation;
|
||||
}
|
||||
}
|
||||
40
Assets/Scripts/Camera Controller/CameraDynamicFOV.cs
Normal file
40
Assets/Scripts/Camera Controller/CameraDynamicFOV.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using static OnlyScove.Scripts.CameraController; // Need to add this to access CameraController.CameraViewMode
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraDynamicFOV
|
||||
{
|
||||
[Header("Dynamic FOV")]
|
||||
[SerializeField] private bool useDynamicFOV = true;
|
||||
[SerializeField] private float tpvSprintFOV = 70f; // Renamed from sprintFOV for clarity
|
||||
[SerializeField] private float fovSmoothTime = 5f;
|
||||
|
||||
private float _currentTpvBaseFOV; // Stored from CameraController
|
||||
private float _currentFpvFOV; // Stored from CameraController
|
||||
|
||||
public float CurrentTpvBaseFOV => _currentTpvBaseFOV; // Expose for CameraController transitions
|
||||
|
||||
public void Initialize(float tpvBaseFOV, float fpvFOV)
|
||||
{
|
||||
_currentTpvBaseFOV = tpvBaseFOV;
|
||||
_currentFpvFOV = fpvFOV;
|
||||
}
|
||||
|
||||
public void HandleDynamicFOV(Camera cam, InputReader inputReader, CameraViewMode viewMode)
|
||||
{
|
||||
if (!useDynamicFOV || cam == null || inputReader == null) return;
|
||||
|
||||
float targetFOV = (viewMode == CameraViewMode.ThirdPerson) ? _currentTpvBaseFOV : _currentFpvFOV;
|
||||
|
||||
// Apply sprint FOV only in TPV
|
||||
if (viewMode == CameraViewMode.ThirdPerson && inputReader.MoveInput.magnitude > 0.1f && inputReader.IsSprintHeld)
|
||||
{
|
||||
targetFOV = tpvSprintFOV;
|
||||
}
|
||||
|
||||
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, fovSmoothTime * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99cfe3471dc945a4fad66b3b440c2c12
|
||||
@@ -0,0 +1,58 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraOcclusionTransparency
|
||||
{
|
||||
[Header("Occlusion Transparency")]
|
||||
[SerializeField] private bool useTransparency = true;
|
||||
[SerializeField] private LayerMask transparencyLayers;
|
||||
[SerializeField] private float fadeAlpha = 0.3f;
|
||||
|
||||
private Renderer _lastFadedRenderer;
|
||||
private Color _originalColor;
|
||||
|
||||
public void HandleTransparency(Transform cameraTransform, Vector3 focusPosition)
|
||||
{
|
||||
if (!useTransparency)
|
||||
{
|
||||
ResetLastRenderer();
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 direction = focusPosition - cameraTransform.position;
|
||||
float distanceToPlayer = direction.magnitude;
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(cameraTransform.position, direction.normalized, out hit, distanceToPlayer, transparencyLayers))
|
||||
{
|
||||
Renderer renderer = hit.collider.GetComponent<Renderer>();
|
||||
if (renderer != null && renderer != _lastFadedRenderer)
|
||||
{
|
||||
ResetLastRenderer();
|
||||
|
||||
_lastFadedRenderer = renderer;
|
||||
_originalColor = renderer.material.color;
|
||||
Color fadedColor = _originalColor;
|
||||
fadedColor.a = fadeAlpha;
|
||||
|
||||
renderer.material.color = fadedColor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetLastRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetLastRenderer()
|
||||
{
|
||||
if (_lastFadedRenderer != null)
|
||||
{
|
||||
_lastFadedRenderer.material.color = _originalColor;
|
||||
_lastFadedRenderer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ad64ce0d02e30243acc55aa0ebc74a9
|
||||
93
Assets/Scripts/Camera Controller/CameraRotationHandler.cs
Normal file
93
Assets/Scripts/Camera Controller/CameraRotationHandler.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using UnityEngine;
|
||||
using static OnlyScove.Scripts.CameraController;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraRotationHandler
|
||||
{
|
||||
[Header("Rotation Settings")]
|
||||
[SerializeField] private float sensitivity = 0.1f;
|
||||
[SerializeField] private float minVerticalAngle = -45f;
|
||||
[SerializeField] private float maxVerticalAngle = 45f;
|
||||
[SerializeField] private bool invertX;
|
||||
[SerializeField] private bool invertY;
|
||||
|
||||
[Header("Auto Rotation")]
|
||||
[SerializeField] private bool useAutoRotation = true;
|
||||
[SerializeField] private float autoRotateDelay = 2.5f;
|
||||
[SerializeField] private float autoRotateSpeed = 2f;
|
||||
|
||||
private float _rotationX;
|
||||
private float _rotationY;
|
||||
private float _lastInputTime;
|
||||
|
||||
public Quaternion CurrentRotation { get; private set; } // Camera's actual rotation
|
||||
public Quaternion PlanarRotation => Quaternion.Euler(0f, _rotationY, 0f); // Horizontal rotation (for player body in FPV)
|
||||
|
||||
public void Initialize(Transform cameraTransform)
|
||||
{
|
||||
_rotationX = cameraTransform.eulerAngles.x;
|
||||
_rotationY = cameraTransform.eulerAngles.y;
|
||||
_lastInputTime = Time.time;
|
||||
CurrentRotation = cameraTransform.rotation;
|
||||
}
|
||||
|
||||
// New method to initialize rotation specifically for FPV
|
||||
public void InitializeFPV(Transform fpvTargetTransform)
|
||||
{
|
||||
_rotationX = fpvTargetTransform.localEulerAngles.x; // Use local rotation for vertical angle in FPV
|
||||
_rotationY = fpvTargetTransform.eulerAngles.y; // Use world rotation for horizontal angle
|
||||
_lastInputTime = Time.time;
|
||||
CurrentRotation = fpvTargetTransform.rotation; // Camera starts matching fpvTarget rotation
|
||||
}
|
||||
|
||||
|
||||
public void HandleRotation(InputReader inputReader, Transform followTarget, float rotationSmoothTime, CameraViewMode viewMode)
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
|
||||
// Debug for rotation
|
||||
if (inputReader.LookInput.sqrMagnitude > 0.001f)
|
||||
{
|
||||
Debug.Log($"[CameraRotationHandler] LookInput: {inputReader.LookInput}, _rotationX: {_rotationX}, _rotationY: {_rotationY}, ViewMode: {viewMode}");
|
||||
}
|
||||
|
||||
// Update _lastInputTime regardless of view mode if there's look input
|
||||
if (inputReader.LookInput.magnitude > 0.01f)
|
||||
{
|
||||
_lastInputTime = Time.time;
|
||||
}
|
||||
|
||||
float invertXVal = (invertX) ? -1 : 1;
|
||||
float invertYVal = (invertY) ? -1 : 1;
|
||||
|
||||
_rotationX -= inputReader.LookInput.y * invertYVal * sensitivity * Time.deltaTime;
|
||||
_rotationX = Mathf.Clamp(_rotationX, minVerticalAngle, maxVerticalAngle);
|
||||
|
||||
_rotationY += inputReader.LookInput.x * invertXVal * sensitivity * Time.deltaTime;
|
||||
|
||||
if (viewMode == CameraViewMode.ThirdPerson)
|
||||
{
|
||||
// Auto-Correction for TPV
|
||||
if (useAutoRotation && Time.time - _lastInputTime > autoRotateDelay)
|
||||
{
|
||||
if (inputReader.MoveInput.magnitude > 0.1f)
|
||||
{
|
||||
float targetYaw = followTarget.eulerAngles.y;
|
||||
_rotationY = Mathf.LerpAngle(_rotationY, targetYaw, autoRotateSpeed * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f);
|
||||
CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
|
||||
}
|
||||
else // FirstPerson
|
||||
{
|
||||
// In FPV, CurrentRotation *is* the camera's rotation (head rotation)
|
||||
// The horizontal part of this (_rotationY) will also be used to rotate the player's body.
|
||||
Quaternion targetRotation = Quaternion.Euler(_rotationX, _rotationY, 0f);
|
||||
CurrentRotation = Quaternion.Slerp(CurrentRotation, targetRotation, rotationSmoothTime * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92ec094a714577d49be74c0fedb3eeb3
|
||||
78
Assets/Scripts/Camera Controller/CameraShakeManager.cs
Normal file
78
Assets/Scripts/Camera Controller/CameraShakeManager.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraShakeManager
|
||||
{
|
||||
[SerializeField] private bool useShake = true;
|
||||
[SerializeField] private float shakeFrequency = 25f; // How fast the shake oscillates
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve decayCurve = AnimationCurve.EaseInOut(0, 1, 1, 0); // How intensity decays over duration
|
||||
|
||||
[Header("Fall Impact Settings")] [SerializeField]
|
||||
private bool enableFallImpactShake = true;
|
||||
|
||||
[SerializeField] private float minFallHeightForShake = 2f;
|
||||
[SerializeField] private float maxFallHeightForShake = 10f;
|
||||
[SerializeField] private float minFallShakeIntensity = 0.5f;
|
||||
[SerializeField] private float maxFallShakeIntensity = 3f;
|
||||
[SerializeField] private float minFallShakeDuration = 0.2f;
|
||||
[SerializeField] private float maxFallShakeDuration = 0.8f;
|
||||
[SerializeField] private AnimationCurve fallHeightToIntensityCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
[SerializeField] private AnimationCurve fallHeightToDurationCurve = AnimationCurve.Linear(0, 0, 1, 1);
|
||||
|
||||
private float _shakeIntensity = 0f;
|
||||
private float _shakeDuration = 0f;
|
||||
private float _shakeTimer = 0f; // Counts down from _shakeDuration
|
||||
private Vector3 _shakeOffset;
|
||||
|
||||
public Vector3 ShakeOffset => _shakeOffset;
|
||||
|
||||
public void HandleShake()
|
||||
{
|
||||
if (!useShake || _shakeTimer <= 0)
|
||||
{
|
||||
_shakeOffset = Vector3.zero;
|
||||
return;
|
||||
}
|
||||
|
||||
_shakeTimer -= Time.deltaTime;
|
||||
float progress = 1f - (_shakeTimer / _shakeDuration); // 0 at start, 1 at end
|
||||
|
||||
// Apply decay curve to intensity
|
||||
float currentIntensity = _shakeIntensity * decayCurve.Evaluate(progress);
|
||||
|
||||
// Use shakeFrequency for Perlin noise
|
||||
float shakeX = (Mathf.PerlinNoise(Time.time * shakeFrequency, 0f) - 0.5f) * 2f;
|
||||
float shakeY = (Mathf.PerlinNoise(0f, Time.time * shakeFrequency) - 0.5f) * 2f;
|
||||
float shakeZ = (Mathf.PerlinNoise(Time.time * shakeFrequency, Time.time * shakeFrequency) - 0.5f) * 2f;
|
||||
|
||||
_shakeOffset = new Vector3(shakeX, shakeY, shakeZ) * currentIntensity;
|
||||
}
|
||||
|
||||
public void Shake(float intensity, float duration)
|
||||
{
|
||||
_shakeIntensity = intensity;
|
||||
_shakeDuration = duration;
|
||||
_shakeTimer = duration; // Reset timer
|
||||
}
|
||||
|
||||
public void TriggerFallImpactShake(float fallHeight)
|
||||
{
|
||||
if (!enableFallImpactShake || fallHeight < minFallHeightForShake) return;
|
||||
|
||||
// Normalize fall height between 0 and 1 relative to min/max thresholds
|
||||
float normalizedFallHeight = Mathf.InverseLerp(minFallHeightForShake, maxFallHeightForShake, fallHeight);
|
||||
|
||||
// Calculate intensity and duration using curves and ranges
|
||||
float intensity = Mathf.Lerp(minFallShakeIntensity, maxFallShakeIntensity,
|
||||
fallHeightToIntensityCurve.Evaluate(normalizedFallHeight));
|
||||
float duration = Mathf.Lerp(minFallShakeDuration, maxFallShakeDuration,
|
||||
fallHeightToDurationCurve.Evaluate(normalizedFallHeight));
|
||||
|
||||
Shake(intensity, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16e87ee63ce87ac4cb7b952772318c0e
|
||||
32
Assets/Scripts/Camera Controller/CameraSideBias.cs
Normal file
32
Assets/Scripts/Camera Controller/CameraSideBias.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraSideBias
|
||||
{
|
||||
[Header("Side Bias")]
|
||||
[SerializeField] private bool useSideBias = true;
|
||||
[SerializeField] private float horizontalBiasAmount = 0.5f;
|
||||
[SerializeField] private float biasSmoothTime = 3f;
|
||||
|
||||
private float _currentSideBias;
|
||||
|
||||
public float CurrentSideBias => _currentSideBias;
|
||||
|
||||
public void HandleSideBias(InputReader inputReader)
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
|
||||
if (useSideBias)
|
||||
{
|
||||
float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount;
|
||||
_currentSideBias = Mathf.Lerp(_currentSideBias, targetBias, biasSmoothTime * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentSideBias = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Camera Controller/CameraSideBias.cs.meta
Normal file
2
Assets/Scripts/Camera Controller/CameraSideBias.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6bf6a3797a87fb4fb086c1625b1e7bb
|
||||
29
Assets/Scripts/Camera Controller/CameraZoomHandler.cs
Normal file
29
Assets/Scripts/Camera Controller/CameraZoomHandler.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class CameraZoomHandler
|
||||
{
|
||||
[Header("Zoom Settings")]
|
||||
[SerializeField] private float distance = 5;
|
||||
[SerializeField] private float minDistance = 2f;
|
||||
[SerializeField] private float maxDistance = 15f;
|
||||
[SerializeField] private float zoomSensitivity = 1f;
|
||||
|
||||
public float CurrentDistance => distance;
|
||||
public float MinDistance => minDistance;
|
||||
|
||||
public void HandleZoom(InputReader inputReader)
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
|
||||
float scrollDelta = inputReader.ScrollInput.y;
|
||||
if (Mathf.Abs(scrollDelta) > 0.1f)
|
||||
{
|
||||
distance -= scrollDelta * zoomSensitivity * Time.deltaTime;
|
||||
distance = Mathf.Clamp(distance, minDistance, maxDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 416c8d0f8adfcbc4390cd2e4e369e0db
|
||||
@@ -1,49 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
/// <summary>
|
||||
/// A version of PlayerStateMachine that simulates constant forward or backward input.
|
||||
/// </summary>
|
||||
public class AutoPlayerStateMachine : PlayerStateMachine
|
||||
{
|
||||
[Header("Auto Pilot Settings")]
|
||||
public bool alwaysMoveForward = true;
|
||||
public bool alwaysRun = true;
|
||||
public bool isRed = false; // New property to differentiate movement direction
|
||||
|
||||
private class FakeInputReader : InputReader
|
||||
{
|
||||
public Vector2 ForcedMove { get; set; }
|
||||
public bool ForcedSprint { get; set; }
|
||||
|
||||
public override Vector2 MoveInput => ForcedMove;
|
||||
public override bool IsSprintHeld => ForcedSprint;
|
||||
}
|
||||
|
||||
private FakeInputReader fakeInput;
|
||||
|
||||
public override InputReader Input => fakeInput;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
fakeInput = gameObject.AddComponent<FakeInputReader>();
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (fakeInput != null)
|
||||
{
|
||||
// Logic updated: isRed moves backward (Vector2.down), others move forward (Vector2.up)
|
||||
fakeInput.ForcedMove = (isRed)
|
||||
? (alwaysMoveForward ? Vector2.down : Vector2.zero)
|
||||
: (alwaysMoveForward ? Vector2.up : Vector2.zero);
|
||||
|
||||
fakeInput.ForcedSprint = alwaysRun;
|
||||
}
|
||||
|
||||
base.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbe8532b2e328a249bf61ae957c92486
|
||||
@@ -1,129 +0,0 @@
|
||||
using UnityEngine;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine.Jobs;
|
||||
using Unity.Burst;
|
||||
|
||||
namespace Elbyss.Optimization
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages 10,000+ objects using C# Job System and Burst Compiler.
|
||||
/// This avoids the overhead of 10,000 individual Update() calls.
|
||||
/// </summary>
|
||||
public class JobsMovementManager : MonoBehaviour
|
||||
{
|
||||
[Header("Spawn Settings")]
|
||||
public GameObject prefab;
|
||||
public int objectCount = 10000;
|
||||
public float spacing = 1.5f;
|
||||
|
||||
[Header("Movement Settings")]
|
||||
public float speed = 5f;
|
||||
|
||||
private TransformAccessArray transformAccessArray;
|
||||
private NativeArray<Vector3> directions;
|
||||
private bool isInitialized = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Optional: Start automatically or via Context Menu
|
||||
// Setup(objectCount);
|
||||
}
|
||||
|
||||
[ContextMenu("Setup 10k Objects")]
|
||||
public void InitialSetup()
|
||||
{
|
||||
Setup(objectCount);
|
||||
}
|
||||
|
||||
public void Setup(int count)
|
||||
{
|
||||
if (isInitialized) Cleanup();
|
||||
|
||||
objectCount = count;
|
||||
Transform[] transforms = new Transform[objectCount];
|
||||
directions = new NativeArray<Vector3>(objectCount, Allocator.Persistent);
|
||||
|
||||
int rowSize = Mathf.CeilToInt(Mathf.Sqrt(objectCount));
|
||||
|
||||
for (int i = 0; i < objectCount; i++)
|
||||
{
|
||||
float x = (i % rowSize) * spacing;
|
||||
float z = (i / rowSize) * spacing;
|
||||
Vector3 pos = transform.position + new Vector3(x, 0, z);
|
||||
|
||||
GameObject go = Instantiate(prefab, pos, Quaternion.identity, this.transform);
|
||||
transforms[i] = go.transform;
|
||||
|
||||
// Set alternating directions
|
||||
directions[i] = (i % 2 == 0) ? Vector3.forward : Vector3.back;
|
||||
|
||||
// CRITICAL OPTIMIZATION: Disable components that are too heavy for 10k objects
|
||||
if (go.TryGetComponent<Animator>(out var anim)) anim.enabled = false;
|
||||
if (go.TryGetComponent<CharacterController>(out var cc)) cc.enabled = false;
|
||||
|
||||
// Disable all other custom scripts
|
||||
MonoBehaviour[] scripts = go.GetComponents<MonoBehaviour>();
|
||||
foreach (var s in scripts)
|
||||
{
|
||||
if (s != this) s.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
transformAccessArray = new TransformAccessArray(transforms);
|
||||
isInitialized = true;
|
||||
Debug.Log($"Initialized {objectCount} objects with Job System.");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!isInitialized) return;
|
||||
|
||||
// Create the movement job
|
||||
var job = new MovementJob
|
||||
{
|
||||
DeltaTime = Time.deltaTime,
|
||||
Speed = speed,
|
||||
Directions = directions
|
||||
};
|
||||
|
||||
// Schedule the job to run in parallel on all available CPU cores
|
||||
// transformAccessArray allows the job to modify Transform data directly
|
||||
JobHandle handle = job.Schedule(transformAccessArray);
|
||||
|
||||
// This ensures the job is finished before the frame ends
|
||||
// In a real scenario, you might want to call Complete() in LateUpdate or next frame
|
||||
// but for simple movement, scheduling and completing in Update is fine.
|
||||
handle.Complete();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
private void Cleanup()
|
||||
{
|
||||
if (isInitialized)
|
||||
{
|
||||
if (transformAccessArray.isCreated) transformAccessArray.Dispose();
|
||||
if (directions.IsCreated) directions.Dispose();
|
||||
isInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
[BurstCompile] // This attribute tells the Burst compiler to optimize this job into machine code
|
||||
struct MovementJob : IJobParallelForTransform
|
||||
{
|
||||
public float DeltaTime;
|
||||
public float Speed;
|
||||
[ReadOnly] public NativeArray<Vector3> Directions;
|
||||
|
||||
public void Execute(int index, TransformAccess transform)
|
||||
{
|
||||
// Directly modify the transform position in parallel
|
||||
transform.position += Directions[index] * Speed * DeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41899df442467714dbee462ae451773a
|
||||
@@ -1,153 +0,0 @@
|
||||
// using GPUInstancerPro;
|
||||
// using Unity.Burst;
|
||||
// using Unity.Collections;
|
||||
// using Unity.Jobs;
|
||||
// using Unity.Mathematics;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace Elbyss.Optimization
|
||||
// {
|
||||
// public class MassiveSpawner : MonoBehaviour
|
||||
// {
|
||||
// [Header("Spawn Settings")]
|
||||
// public GameObject prefab;
|
||||
// public GPUIProfile profile;
|
||||
// public int instanceCount = 100000;
|
||||
// public float spacing = 1.5f;
|
||||
//
|
||||
// [Header("Update Settings")]
|
||||
// public bool runUpdate = true;
|
||||
// public float movementSpeed = 1.0f;
|
||||
// public float amplitude = 2.0f;
|
||||
//
|
||||
// private int _rendererKey;
|
||||
// private NativeArray<Matrix4x4> _matrices;
|
||||
// private JobHandle _jobHandle;
|
||||
// private bool _isInitialized;
|
||||
//
|
||||
// private void OnEnable()
|
||||
// {
|
||||
// Initialize();
|
||||
// }
|
||||
//
|
||||
// private void OnDisable()
|
||||
// {
|
||||
// Dispose();
|
||||
// }
|
||||
//
|
||||
// private void OnValidate()
|
||||
// {
|
||||
// if (Application.isPlaying && _isInitialized)
|
||||
// {
|
||||
// // Re-initialize if count changes during play (optional, but good for testing)
|
||||
// Initialize();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Initialize()
|
||||
// {
|
||||
// Dispose();
|
||||
// if (prefab == null) return;
|
||||
//
|
||||
// if (GPUICoreAPI.RegisterRenderer(this, prefab, profile, out _rendererKey))
|
||||
// {
|
||||
// _matrices = new NativeArray<Matrix4x4>(instanceCount, Allocator.Persistent);
|
||||
//
|
||||
// // Initial generation
|
||||
// GenerateMatrices(0);
|
||||
// _jobHandle.Complete();
|
||||
// GPUICoreAPI.SetTransformBufferData(_rendererKey, _matrices);
|
||||
//
|
||||
// _isInitialized = true;
|
||||
// Debug.Log($"[MassiveSpawner] Registered {instanceCount} instances with key {_rendererKey}");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("[MassiveSpawner] Failed to register renderer!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void Update()
|
||||
// {
|
||||
// if (!_isInitialized || _rendererKey == 0) return;
|
||||
//
|
||||
// if (runUpdate)
|
||||
// {
|
||||
// // Complete previous frame's work if any
|
||||
// _jobHandle.Complete();
|
||||
//
|
||||
// // Apply updated matrices to GPUI
|
||||
// GPUICoreAPI.SetTransformBufferData(_rendererKey, _matrices);
|
||||
//
|
||||
// // Schedule next frame's work
|
||||
// GenerateMatrices(Time.time);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void GenerateMatrices(float time)
|
||||
// {
|
||||
// int side = Mathf.CeilToInt(Mathf.Sqrt(instanceCount));
|
||||
//
|
||||
// var job = new MatrixUpdateJob
|
||||
// {
|
||||
// matrices = _matrices,
|
||||
// side = side,
|
||||
// spacing = spacing,
|
||||
// time = time,
|
||||
// speed = movementSpeed,
|
||||
// amplitude = amplitude,
|
||||
// origin = transform.position
|
||||
// };
|
||||
//
|
||||
// _jobHandle = job.Schedule(instanceCount, 64);
|
||||
// }
|
||||
//
|
||||
// public void Dispose()
|
||||
// {
|
||||
// _jobHandle.Complete();
|
||||
// if (_rendererKey != 0)
|
||||
// {
|
||||
// GPUICoreAPI.DisposeRenderer(_rendererKey);
|
||||
// _rendererKey = 0;
|
||||
// }
|
||||
//
|
||||
// if (_matrices.IsCreated)
|
||||
// {
|
||||
// _matrices.Dispose();
|
||||
// }
|
||||
// _isInitialized = false;
|
||||
// }
|
||||
//
|
||||
// [BurstCompile]
|
||||
// struct MatrixUpdateJob : IJobParallelFor
|
||||
// {
|
||||
// public NativeArray<Matrix4x4> matrices;
|
||||
// public int side;
|
||||
// public float spacing;
|
||||
// public float time;
|
||||
// public float speed;
|
||||
// public float amplitude;
|
||||
// public Vector3 origin;
|
||||
//
|
||||
// public void Execute(int index)
|
||||
// {
|
||||
// int x = index % side;
|
||||
// int z = index / side;
|
||||
//
|
||||
// float xPos = x * spacing;
|
||||
// float zPos = z * spacing;
|
||||
//
|
||||
// // Add some animation to prove it's updating
|
||||
// float yPos = math.sin(time * speed + (xPos + zPos) * 0.1f) * amplitude;
|
||||
//
|
||||
// Vector3 pos = origin + new Vector3(xPos, yPos, zPos);
|
||||
//
|
||||
// // Simple rotation based on time
|
||||
// float angle = (time * speed * 10f + index) % 360f;
|
||||
// Quaternion rot = Quaternion.Euler(0, angle, 0);
|
||||
//
|
||||
// matrices[index] = Matrix4x4.TRS(pos, rot, Vector3.one);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50831f537cbccac4c9bf4067b6b158c7
|
||||
@@ -1,34 +0,0 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
namespace Elbyss.Optimization
|
||||
{
|
||||
public class PerformanceHUD : MonoBehaviour
|
||||
{
|
||||
private float deltaTime = 0.0f;
|
||||
private string displayFormat = "{0:0.0} ms ({1:0.} fps)";
|
||||
|
||||
private void Update()
|
||||
{
|
||||
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
int w = Screen.width, h = Screen.height;
|
||||
|
||||
GUIStyle style = new GUIStyle();
|
||||
|
||||
Rect rect = new Rect(10, 10, w, h * 2 / 100);
|
||||
style.alignment = TextAnchor.UpperLeft;
|
||||
style.fontSize = h * 2 / 50;
|
||||
style.normal.textColor = new Color(0.0f, 1.0f, 0.5f, 1.0f);
|
||||
|
||||
float msec = deltaTime * 1000.0f;
|
||||
float fps = 1.0f / deltaTime;
|
||||
string text = string.Format(displayFormat, msec, fps);
|
||||
|
||||
GUI.Label(rect, text, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c9a374a3ab089d41a6784b1ffad3b6f
|
||||
@@ -1,85 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using OnlyScove.Scripts;
|
||||
|
||||
namespace Elbyss.Optimization
|
||||
{
|
||||
public class StressTestSpawner : MonoBehaviour
|
||||
{
|
||||
[Header("Spawn Settings")]
|
||||
public GameObject prefabToSpawn;
|
||||
public int spawnLimit = 1000;
|
||||
public int spawnsPerFrame = 10;
|
||||
public float spacing = 2.0f;
|
||||
|
||||
[Header("Testing Mode")]
|
||||
public bool useAutoStateMachine = true;
|
||||
|
||||
[Header("Optimization Options")]
|
||||
public bool stripHeavyComponents = false;
|
||||
|
||||
private List<GameObject> spawnedObjects = new List<GameObject>();
|
||||
private int currentSpawnCount = 0;
|
||||
private bool isSpawning = false;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isSpawning && currentSpawnCount < spawnLimit)
|
||||
{
|
||||
for (int i = 0; i < spawnsPerFrame && currentSpawnCount < spawnLimit; i++)
|
||||
{
|
||||
SpawnObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Start Stress Test")]
|
||||
public void StartStressTest() => isSpawning = true;
|
||||
|
||||
[ContextMenu("Clear All")]
|
||||
public void ClearAll()
|
||||
{
|
||||
foreach (var obj in spawnedObjects) if (obj != null) Destroy(obj);
|
||||
spawnedObjects.Clear();
|
||||
currentSpawnCount = 0;
|
||||
isSpawning = false;
|
||||
}
|
||||
|
||||
private void SpawnObject()
|
||||
{
|
||||
if (prefabToSpawn == null) return;
|
||||
|
||||
int rowSize = Mathf.CeilToInt(Mathf.Sqrt(spawnLimit));
|
||||
float x = (currentSpawnCount % rowSize) * spacing;
|
||||
float z = (currentSpawnCount / rowSize) * spacing;
|
||||
Vector3 spawnPos = transform.position + new Vector3(x, 0, z);
|
||||
|
||||
GameObject newObj = Instantiate(prefabToSpawn, spawnPos, transform.rotation);
|
||||
|
||||
if (useAutoStateMachine)
|
||||
{
|
||||
var realInput = newObj.GetComponent<InputReader>();
|
||||
if (realInput != null) realInput.enabled = false;
|
||||
|
||||
var originalSM = newObj.GetComponent<PlayerStateMachine>();
|
||||
if (originalSM != null)
|
||||
{
|
||||
DestroyImmediate(originalSM);
|
||||
var autoSM = newObj.AddComponent<AutoPlayerStateMachine>();
|
||||
autoSM.alwaysMoveForward = true;
|
||||
autoSM.alwaysRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (stripHeavyComponents)
|
||||
{
|
||||
if (newObj.TryGetComponent<Animator>(out var anim)) anim.enabled = false;
|
||||
if (newObj.TryGetComponent<CharacterController>(out var cc)) cc.enabled = false;
|
||||
if (newObj.TryGetComponent<PlayerStateMachine>(out var sm)) sm.enabled = false;
|
||||
}
|
||||
|
||||
spawnedObjects.Add(newObj);
|
||||
currentSpawnCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a7c5ef310b7f354685dc6706be2d530
|
||||
@@ -21,6 +21,7 @@ namespace OnlyScove.Scripts
|
||||
public event Action OnInteractEvent; // E Key
|
||||
public event Action OnNextInteractEvent; // R Key
|
||||
public event Action OnPreviousInteractEvent; // Q Key
|
||||
public event Action OnToggleViewEvent; // F2 - New event for toggling camera view
|
||||
|
||||
public void OnAttack(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -56,6 +57,15 @@ namespace OnlyScove.Scripts
|
||||
if (context.canceled) IsSprintHeld = false;
|
||||
}
|
||||
|
||||
// New method for ToggleView input
|
||||
public void OnToggleView(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed)
|
||||
{
|
||||
OnToggleViewEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnJump(InputAction.CallbackContext context)
|
||||
{
|
||||
if (context.performed) OnJumpEvent?.Invoke();
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class ParkourController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private InputReader inputReader;
|
||||
EnvironmentScanner environmentScanner;
|
||||
Animator animator;
|
||||
PlayerController playerController;
|
||||
|
||||
bool inAction;
|
||||
private void Awake()
|
||||
{
|
||||
inputReader = GetComponent<InputReader>();
|
||||
environmentScanner = GetComponent<EnvironmentScanner>();
|
||||
animator = GetComponent<Animator>();
|
||||
playerController = GetComponent<PlayerController>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inputReader.OnJumpEvent += HandleParkour;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
inputReader.OnJumpEvent -= HandleParkour;
|
||||
}
|
||||
|
||||
private void HandleParkour()
|
||||
{
|
||||
var hitData = environmentScanner.ObstacleCheck();
|
||||
|
||||
if (hitData.forwardHitFound)
|
||||
{
|
||||
StartCoroutine(DoParkourAction());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator DoParkourAction()
|
||||
{
|
||||
inAction = true;
|
||||
playerController.SetControl(false);
|
||||
|
||||
animator.CrossFade("Step Up", 0.1f);
|
||||
yield return null;
|
||||
|
||||
var animationState = animator.GetNextAnimatorStateInfo(0);
|
||||
|
||||
yield return new WaitForSeconds(animationState.length);
|
||||
|
||||
playerController.SetControl(true);
|
||||
inAction = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0407ea3fbe445ac43b4f1ca3077ce283
|
||||
@@ -1,134 +0,0 @@
|
||||
using System;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class PlayerController : MonoBehaviour
|
||||
{
|
||||
private static readonly int MoveAmount = Animator.StringToHash("moveAmount");
|
||||
|
||||
[SerializeField] private InputReader inputReader;
|
||||
[SerializeField] private float rotationSpeed = 500f;
|
||||
[SerializeField] private float moveSpeed = 10f;
|
||||
[SerializeField] private float jumpHeight = 2f;
|
||||
[SerializeField] private float animationDamping = 0.2f;
|
||||
[SerializeField] private float groundCheckRadius = 0.2f;
|
||||
[SerializeField] private Vector3 groundCheckOffset;
|
||||
[SerializeField] private LayerMask groundMask;
|
||||
|
||||
CameraController cameraController;
|
||||
Animator animator;
|
||||
private CharacterController characterController;
|
||||
|
||||
Quaternion targetRotation;
|
||||
private float horizontal;
|
||||
private float vertical;
|
||||
bool isGrounded;
|
||||
private bool wasGrounded;
|
||||
private bool hasControl = true;
|
||||
private float ySpeed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Camera.main != null) cameraController = Camera.main.GetComponent<CameraController>();
|
||||
animator = GetComponent<Animator>();
|
||||
characterController = GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inputReader.OnJumpEvent += HandleJump;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
inputReader.OnJumpEvent -= HandleJump;
|
||||
}
|
||||
|
||||
private void HandleJump()
|
||||
{
|
||||
if (isGrounded && hasControl)
|
||||
{
|
||||
// Công thức tính vận tốc nhảy: v = sqrt(h * -2 * g)
|
||||
ySpeed = Mathf.Sqrt(jumpHeight * -2f * Physics.gravity.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
horizontal = inputReader.MoveInput.x;
|
||||
vertical = inputReader.MoveInput.y;
|
||||
float moveAmount = Mathf.Clamp01(Math.Abs(horizontal) + Math.Abs(vertical));
|
||||
|
||||
var moveInput = (new Vector3(horizontal, 0, vertical)).normalized;
|
||||
|
||||
var moveDirection = cameraController.PlanarRotation * moveInput;
|
||||
|
||||
if (!hasControl)
|
||||
return;
|
||||
|
||||
wasGrounded = isGrounded;
|
||||
GroundCheck();
|
||||
|
||||
// Phát hiện tiếp đất (Landing)
|
||||
if (isGrounded && !wasGrounded && ySpeed < -1f)
|
||||
{
|
||||
// Rung camera khi tiếp đất mạnh
|
||||
if (cameraController != null)
|
||||
{
|
||||
cameraController.Shake(0.2f, 0.15f);
|
||||
}
|
||||
}
|
||||
|
||||
if (isGrounded && ySpeed < 0)
|
||||
{
|
||||
ySpeed = -2f; // Giữ nhân vật dính xuống mặt đất
|
||||
}
|
||||
else
|
||||
{
|
||||
ySpeed += Physics.gravity.y * Time.deltaTime;
|
||||
}
|
||||
|
||||
var velocity = moveDirection * moveSpeed;
|
||||
velocity.y = ySpeed;
|
||||
|
||||
characterController.Move(velocity * Time.deltaTime);
|
||||
|
||||
if (moveAmount > 0)
|
||||
{
|
||||
targetRotation = Quaternion.LookRotation(moveDirection);
|
||||
|
||||
}
|
||||
|
||||
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation,
|
||||
Time.deltaTime * rotationSpeed);
|
||||
|
||||
animator.SetFloat(MoveAmount, moveAmount, animationDamping, Time.deltaTime);
|
||||
}
|
||||
|
||||
void GroundCheck()
|
||||
{
|
||||
isGrounded =
|
||||
Physics.CheckSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius, groundMask);
|
||||
}
|
||||
|
||||
public void SetControl(bool control)
|
||||
{
|
||||
this.hasControl = control;
|
||||
characterController.enabled = hasControl;
|
||||
|
||||
if (!hasControl)
|
||||
{
|
||||
animator.SetFloat(MoveAmount, 0f);
|
||||
targetRotation = transform.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
Gizmos.color = new Color(0, 1, 0, 0.5f);
|
||||
Gizmos.DrawSphere(transform.TransformPoint(groundCheckOffset), groundCheckRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd897e8bcaabdc8408bb6aaf7c037537
|
||||
@@ -36,6 +36,11 @@ namespace OnlyScove.Scripts
|
||||
Vector3 inputDir = new Vector3(input.x, 0, input.y).normalized;
|
||||
Vector3 moveDirection = stateMachine.Cam != null ? stateMachine.Cam.PlanarRotation * inputDir : inputDir;
|
||||
|
||||
if (stateMachine.Cam != null)
|
||||
{
|
||||
Debug.Log($"[PlayerMoveState] View: {(stateMachine.Cam.PlanarRotation.eulerAngles.y)}, InputDir: {inputDir}, MoveDir: {moveDirection}, PlayerRot: {stateMachine.transform.rotation.eulerAngles.y}");
|
||||
}
|
||||
|
||||
Vector3 velocity = moveDirection * stateMachine.RunSpeed;
|
||||
|
||||
if (stateMachine.IsGrounded && stateMachine.VelocityY < 0)
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
// -- SPINE PROXY 1.0 | Kevin Iglesias --
|
||||
// This script ensures correct animation display when mixing upper and lower body animations using Unity Avatar Masks.
|
||||
// Attach this script to the 'B-spineProxy' transform, which is a sibling of the 'B-hips' bone.
|
||||
// In the 'originalSpine' field, assign the 'B-spine' bone (child of 'B-hips' and parent of 'B-chest').
|
||||
// By default it will automatically find the 'B-spine' and assign it to the 'originalSpine' field (OnValidate).
|
||||
// When using a different character rig, manually assign the corresponding spine bone to the 'originalSpine' field and recreate
|
||||
// 'Rig > B-root > B-spine' structure in your character hierarchy with empty GameObjects.
|
||||
|
||||
// More information: https://www.keviniglesias.com/spine-proxy.html
|
||||
// Contact Support: support@keviniglesias.com
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace KevinIglesias
|
||||
{
|
||||
public class SpineProxy : MonoBehaviour
|
||||
{
|
||||
//Assign 'B-spine' (or equivalent) here:
|
||||
[SerializeField] private Transform originalSpine;
|
||||
|
||||
private Quaternion rotationOffset = Quaternion.identity;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
//Attempting to find the original spine bone.
|
||||
void OnValidate()
|
||||
{
|
||||
if(originalSpine == null)
|
||||
{
|
||||
Transform parent = transform.parent;
|
||||
if(parent != null)
|
||||
{
|
||||
Transform hips = parent.Find("B-hips");
|
||||
if(hips != null)
|
||||
{
|
||||
Transform spine = hips.Find("B-spine");
|
||||
if(spine != null)
|
||||
{
|
||||
originalSpine = spine;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//Match correct orientation on different character rigs
|
||||
void Awake()
|
||||
{
|
||||
if(originalSpine != null)
|
||||
{//originalSpine.rotation must be the default rotation in your character T-pose when this happens:
|
||||
rotationOffset = Quaternion.Inverse(transform.rotation) * originalSpine.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
//Copy rotations from spine proxy bone to the original spine bone.
|
||||
void LateUpdate()
|
||||
{
|
||||
if(originalSpine == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
originalSpine.rotation = transform.rotation * rotationOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 682245d9ac89ba4409aa3a92f17f5c6c
|
||||
@@ -60,10 +60,10 @@ MonoBehaviour:
|
||||
- folder: {fileID: 102900000, guid: 8c41df02b38b2ee40b792b146c0493f2, type: 3}
|
||||
folderIcon: {fileID: 2800000, guid: 9687b8a9002844d4b8ece997ce390043, type: 3}
|
||||
overlayIcon: {fileID: 0}
|
||||
- folder: {fileID: 102900000, guid: f2f1b47c5ca0ce34d8a018d4bf5a91d8, type: 3}
|
||||
- folder: {fileID: 102900000, guid: 4e6e9b4a0c2e35242b749c3b025c2b6d, type: 3}
|
||||
folderIcon: {fileID: 2800000, guid: 45c44e19279856a4084f599ece9e9f38, type: 3}
|
||||
overlayIcon: {fileID: 0}
|
||||
- folder: {fileID: 102900000, guid: 36bac883f43f8284d865986ec721bf93, type: 3}
|
||||
- folder: {fileID: 102900000, guid: e4342b7ac2b8c524bbfd5ed650d13a32, type: 3}
|
||||
folderIcon: {fileID: 2800000, guid: e73175098a6e2ea4db2ac2e6530f2b19, type: 3}
|
||||
overlayIcon: {fileID: 0}
|
||||
- folder: {fileID: 102900000, guid: b7be1da6c24fb324cb1b67eb7a5e6426, type: 3}
|
||||
|
||||
Reference in New Issue
Block a user