Import assets from store
This commit is contained in:
1 parent
a05f2e47a2
commit
376e52e323
875 files changed
+128037
No files matched your search
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dd4a0e467d3e81499bd5c06cee2aa5b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fba3bf02ac126349b59106200fc8907
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "CharacterMovement.Core",
|
||||
"rootNamespace": "CharacterMovement",
|
||||
"references": [
|
||||
"Unity.InputSystem"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.textmeshpro",
|
||||
"expression": "[3.0.6,)",
|
||||
"define": "CC_TMP_AVAILABLE"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89bb7cdb87daffb439577e85d5b0c3f8
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/CharacterMovement.Core.asmdef
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f5b56ec6ce84c5faf93ef803d39b827
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f6f5dbdbb9e844948b4a51538e11f142, type: 3}
|
||||
m_Name: ArcadeFPSMotorSettings
|
||||
m_EditorClassIdentifier:
|
||||
runSpeed: 6
|
||||
sprintSpeed: 9.5
|
||||
walkSpeed: 3
|
||||
crouchSpeed: 3
|
||||
proneSpeed: 1.7
|
||||
groundAcceleration: 60
|
||||
groundDeceleration: 65
|
||||
airAcceleration: 20
|
||||
airDeceleration: 4
|
||||
jumpingForce: 8.7
|
||||
canMoveWhileJumping: 1
|
||||
coyoteTime: 0.18
|
||||
jumpBufferTime: 0.16
|
||||
parkourBufferTime: 0.16
|
||||
gravityScale: 1.15
|
||||
maxFallSpeed: 35
|
||||
crouchCapsuleHeight: 1.15
|
||||
proneCapsuleHeight: 0.55
|
||||
stanceTransitionSpeed: 18
|
||||
slideDuration: 0.65
|
||||
slideStartSpeed: 10.5
|
||||
slideEndSpeed: 3.2
|
||||
slideSteeringStrength: 0.55
|
||||
slideCooldownDuration: 0.35
|
||||
minimumSlideInputSpeed: 5.8
|
||||
maxSlopeAngle: 48
|
||||
maxStairsAngle: 62
|
||||
groundProbeRadiusScale: 0.95
|
||||
groundSnapDistance: 0.2
|
||||
groundStickForce: 26
|
||||
stepHeight: 0.38
|
||||
stepCheckDistance: 0.24
|
||||
stepProbeRadiusScale: 0.85
|
||||
ceilingCheckDistance: 0.05
|
||||
uphillSlopeSpeedMultiplier: 0.95
|
||||
downhillSlopeSpeedMultiplier: 1.08
|
||||
slideForce: 16
|
||||
slopeAlignment: 6
|
||||
alignToSlopeNormal: 0
|
||||
externalForceDrag: 6
|
||||
variableJumpHeight: 1
|
||||
jumpCutMultiplier: 0.45
|
||||
fallGravityMultiplier: 1.6
|
||||
jumpGraceDuration: 0.08
|
||||
maxSlopeSlideSpeed: 12
|
||||
ceilingProbeRadiusScale: 0.95
|
||||
stanceClearanceRadiusScale: 0.95
|
||||
useSupplementaryGroundRays: 1
|
||||
supplementaryRaySpread: 0.3
|
||||
groundProbeLiftOffset: 0.05
|
||||
groundProbeEpsilon: 0.05
|
||||
airborneLaunchVelocityThreshold: 0.1
|
||||
fallDetectionVelocityThreshold: 0.05
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1275ec8972ea48db914c5137194f8f8f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Data/ArcadeFPSMotorSettings.asset
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,35 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 48eb654a49d14d5998664661cf5b635e, type: 3}
|
||||
m_Name: DefaultCharacterAnimatorParameters
|
||||
m_EditorClassIdentifier:
|
||||
speed: Speed
|
||||
planarSpeed: PlanarSpeed
|
||||
forward: Forward
|
||||
strafe: Strafe
|
||||
isGrounded: IsGrounded
|
||||
isFalling: IsFalling
|
||||
isJumping: IsJumping
|
||||
isSprinting: IsSprinting
|
||||
isCrouching: IsCrouching
|
||||
isProne: IsProne
|
||||
isSliding: IsSliding
|
||||
stance: Stance
|
||||
movementState: MovementState
|
||||
jumpStarted: JumpStarted
|
||||
landed: Landed
|
||||
slideStarted: SlideStarted
|
||||
slideEnded: SlideEnded
|
||||
vaultStarted: VaultStarted
|
||||
vaultEnded: VaultEnded
|
||||
mantleStarted: MantleStarted
|
||||
mantleEnded: MantleEnded
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 115a6e0d9384461186f8d5ce9ab282b4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Data/DefaultCharacterAnimatorParameters.asset
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,67 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f6f5dbdbb9e844948b4a51538e11f142, type: 3}
|
||||
m_Name: ParkourLiteMotorSettings
|
||||
m_EditorClassIdentifier:
|
||||
runSpeed: 6
|
||||
sprintSpeed: 8.8
|
||||
walkSpeed: 2.8
|
||||
crouchSpeed: 3
|
||||
proneSpeed: 1.4
|
||||
groundAcceleration: 50
|
||||
groundDeceleration: 46
|
||||
airAcceleration: 16
|
||||
airDeceleration: 2.5
|
||||
jumpingForce: 8.5
|
||||
canMoveWhileJumping: 1
|
||||
coyoteTime: 0.18
|
||||
jumpBufferTime: 0.16
|
||||
parkourBufferTime: 0.18
|
||||
gravityScale: 1.15
|
||||
maxFallSpeed: 34
|
||||
crouchCapsuleHeight: 1.15
|
||||
proneCapsuleHeight: 0.55
|
||||
stanceTransitionSpeed: 16
|
||||
slideDuration: 0.8
|
||||
slideStartSpeed: 10
|
||||
slideEndSpeed: 3
|
||||
slideSteeringStrength: 0.5
|
||||
slideCooldownDuration: 0.4
|
||||
minimumSlideInputSpeed: 5.5
|
||||
maxSlopeAngle: 50
|
||||
maxStairsAngle: 64
|
||||
groundProbeRadiusScale: 0.95
|
||||
groundSnapDistance: 0.22
|
||||
groundStickForce: 24
|
||||
stepHeight: 0.42
|
||||
stepCheckDistance: 0.25
|
||||
stepProbeRadiusScale: 0.85
|
||||
ceilingCheckDistance: 0.05
|
||||
uphillSlopeSpeedMultiplier: 0.92
|
||||
downhillSlopeSpeedMultiplier: 1.08
|
||||
slideForce: 18
|
||||
slopeAlignment: 6
|
||||
alignToSlopeNormal: 0
|
||||
externalForceDrag: 5.5
|
||||
variableJumpHeight: 1
|
||||
jumpCutMultiplier: 0.35
|
||||
fallGravityMultiplier: 1.45
|
||||
jumpGraceDuration: 0.1
|
||||
maxSlopeSlideSpeed: 14
|
||||
ceilingProbeRadiusScale: 0.95
|
||||
stanceClearanceRadiusScale: 0.92
|
||||
useSupplementaryGroundRays: 1
|
||||
supplementaryRaySpread: 0.35
|
||||
groundProbeLiftOffset: 0.05
|
||||
groundProbeEpsilon: 0.05
|
||||
airborneLaunchVelocityThreshold: 0.1
|
||||
fallDetectionVelocityThreshold: 0.05
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2369305b59714da2a1afcd9fc25ec7b1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Data/ParkourLiteMotorSettings.asset
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,67 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f6f5dbdbb9e844948b4a51538e11f142, type: 3}
|
||||
m_Name: TacticalFPSMotorSettings
|
||||
m_EditorClassIdentifier:
|
||||
runSpeed: 5.2
|
||||
sprintSpeed: 8
|
||||
walkSpeed: 2.2
|
||||
crouchSpeed: 2.4
|
||||
proneSpeed: 1.2
|
||||
groundAcceleration: 42
|
||||
groundDeceleration: 48
|
||||
airAcceleration: 11
|
||||
airDeceleration: 1.5
|
||||
jumpingForce: 8
|
||||
canMoveWhileJumping: 1
|
||||
coyoteTime: 0.15
|
||||
jumpBufferTime: 0.12
|
||||
parkourBufferTime: 0.12
|
||||
gravityScale: 1.25
|
||||
maxFallSpeed: 32
|
||||
crouchCapsuleHeight: 1.15
|
||||
proneCapsuleHeight: 0.55
|
||||
stanceTransitionSpeed: 14
|
||||
slideDuration: 0.72
|
||||
slideStartSpeed: 9
|
||||
slideEndSpeed: 2.6
|
||||
slideSteeringStrength: 0.35
|
||||
slideCooldownDuration: 0.45
|
||||
minimumSlideInputSpeed: 5.5
|
||||
maxSlopeAngle: 45
|
||||
maxStairsAngle: 60
|
||||
groundProbeRadiusScale: 0.95
|
||||
groundSnapDistance: 0.18
|
||||
groundStickForce: 24
|
||||
stepHeight: 0.35
|
||||
stepCheckDistance: 0.2
|
||||
stepProbeRadiusScale: 0.85
|
||||
ceilingCheckDistance: 0.05
|
||||
uphillSlopeSpeedMultiplier: 0.9
|
||||
downhillSlopeSpeedMultiplier: 1.05
|
||||
slideForce: 15
|
||||
slopeAlignment: 5
|
||||
alignToSlopeNormal: 0
|
||||
externalForceDrag: 5
|
||||
variableJumpHeight: 0
|
||||
jumpCutMultiplier: 1
|
||||
fallGravityMultiplier: 1.35
|
||||
jumpGraceDuration: 0.08
|
||||
maxSlopeSlideSpeed: 9
|
||||
ceilingProbeRadiusScale: 0.95
|
||||
stanceClearanceRadiusScale: 0.95
|
||||
useSupplementaryGroundRays: 1
|
||||
supplementaryRaySpread: 0.3
|
||||
groundProbeLiftOffset: 0.05
|
||||
groundProbeEpsilon: 0.05
|
||||
airborneLaunchVelocityThreshold: 0.1
|
||||
fallDetectionVelocityThreshold: 0.05
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1d93cadb86c4b8d9f7d859175d96781
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Data/TacticalFPSMotorSettings.asset
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,67 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f6f5dbdbb9e844948b4a51538e11f142, type: 3}
|
||||
m_Name: ThirdPersonRPGMotorSettings
|
||||
m_EditorClassIdentifier:
|
||||
runSpeed: 4.8
|
||||
sprintSpeed: 6.5
|
||||
walkSpeed: 2
|
||||
crouchSpeed: 2.2
|
||||
proneSpeed: 1.1
|
||||
groundAcceleration: 28
|
||||
groundDeceleration: 34
|
||||
airAcceleration: 7
|
||||
airDeceleration: 1.25
|
||||
jumpingForce: 7.2
|
||||
canMoveWhileJumping: 1
|
||||
coyoteTime: 0.14
|
||||
jumpBufferTime: 0.12
|
||||
parkourBufferTime: 0.1
|
||||
gravityScale: 1
|
||||
maxFallSpeed: 25
|
||||
crouchCapsuleHeight: 1.15
|
||||
proneCapsuleHeight: 0.55
|
||||
stanceTransitionSpeed: 12
|
||||
slideDuration: 0.75
|
||||
slideStartSpeed: 7.2
|
||||
slideEndSpeed: 2.3
|
||||
slideSteeringStrength: 0.25
|
||||
slideCooldownDuration: 0.6
|
||||
minimumSlideInputSpeed: 5.2
|
||||
maxSlopeAngle: 45
|
||||
maxStairsAngle: 60
|
||||
groundProbeRadiusScale: 0.95
|
||||
groundSnapDistance: 0.18
|
||||
groundStickForce: 22
|
||||
stepHeight: 0.35
|
||||
stepCheckDistance: 0.2
|
||||
stepProbeRadiusScale: 0.85
|
||||
ceilingCheckDistance: 0.05
|
||||
uphillSlopeSpeedMultiplier: 0.85
|
||||
downhillSlopeSpeedMultiplier: 1.03
|
||||
slideForce: 13
|
||||
slopeAlignment: 5
|
||||
alignToSlopeNormal: 1
|
||||
externalForceDrag: 5
|
||||
variableJumpHeight: 0
|
||||
jumpCutMultiplier: 1
|
||||
fallGravityMultiplier: 1.2
|
||||
jumpGraceDuration: 0.08
|
||||
maxSlopeSlideSpeed: 8
|
||||
ceilingProbeRadiusScale: 0.95
|
||||
stanceClearanceRadiusScale: 0.95
|
||||
useSupplementaryGroundRays: 1
|
||||
supplementaryRaySpread: 0.3
|
||||
groundProbeLiftOffset: 0.05
|
||||
groundProbeEpsilon: 0.05
|
||||
airborneLaunchVelocityThreshold: 0.1
|
||||
fallDetectionVelocityThreshold: 0.05
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05dcf05bb5654e88ad557914665cd9e1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Data/ThirdPersonRPGMotorSettings.asset
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04a130700039c4e4bb3d6031cec75706
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+849
@@ -0,0 +1,849 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Motion Core Character Controller - Manual</title>
|
||||
<style>
|
||||
:root{
|
||||
--ink:#1c2330; --muted:#5b6472; --line:#dfe3ea; --accent:#3b5bdb;
|
||||
--accent-soft:#eef2ff; --code-bg:#f5f6f8; --warn:#fff4e5; --warn-line:#f0b429;
|
||||
}
|
||||
*{box-sizing:border-box;}
|
||||
html{-webkit-print-color-adjust:exact; print-color-adjust:exact;}
|
||||
body{
|
||||
font-family:"Segoe UI",Arial,Helvetica,sans-serif; color:var(--ink);
|
||||
line-height:1.55; margin:0; font-size:15px; background:#fff;
|
||||
}
|
||||
.page{max-width:820px; margin:0 auto; padding:40px 48px;}
|
||||
h1,h2,h3{line-height:1.25; font-weight:700;}
|
||||
h2.sec{
|
||||
font-size:22px; margin:34px 0 12px; padding-bottom:6px;
|
||||
border-bottom:2px solid var(--accent); color:var(--ink);
|
||||
}
|
||||
h3{font-size:17px; margin:22px 0 8px; color:#28324a;}
|
||||
p{margin:10px 0;}
|
||||
a{color:var(--accent); text-decoration:none;}
|
||||
ul,ol{margin:10px 0 10px 24px; padding:0;}
|
||||
li{margin:4px 0;}
|
||||
code{
|
||||
font-family:"Cascadia Code",Consolas,"Courier New",monospace; font-size:.88em;
|
||||
background:var(--code-bg); padding:1px 5px; border-radius:4px; color:#294;
|
||||
}
|
||||
pre{
|
||||
background:var(--code-bg); border:1px solid var(--line); border-radius:8px;
|
||||
padding:14px 16px; overflow-x:auto; margin:12px 0;
|
||||
}
|
||||
pre code{background:none; padding:0; color:var(--ink); font-size:.85em;}
|
||||
.callout{
|
||||
background:var(--accent-soft); border-left:4px solid var(--accent);
|
||||
border-radius:6px; padding:12px 16px; margin:16px 0;
|
||||
}
|
||||
.callout-title{font-weight:700; color:var(--accent); font-size:13px;
|
||||
text-transform:uppercase; letter-spacing:.04em; margin-bottom:2px;}
|
||||
.callout p{margin:0;}
|
||||
|
||||
/* Screenshot slots */
|
||||
figure.shot{margin:18px 0; page-break-inside:avoid;}
|
||||
.shot-frame{border:1px solid var(--line); border-radius:8px; overflow:hidden;}
|
||||
.shot-frame img{display:block; width:100%; height:auto;}
|
||||
.shot-frame.missing{
|
||||
border:2px dashed var(--accent); background:repeating-linear-gradient(
|
||||
45deg,#fafbff,#fafbff 12px,#f1f4ff 12px,#f1f4ff 24px);
|
||||
}
|
||||
.shot-slot{display:none; padding:26px 22px; text-align:center;}
|
||||
.shot-frame.missing .shot-slot{display:block;}
|
||||
.shot-tag{display:inline-block; background:var(--accent); color:#fff;
|
||||
font-size:11px; font-weight:700; letter-spacing:.08em; padding:3px 10px;
|
||||
border-radius:20px; margin-bottom:10px;}
|
||||
.shot-cap{display:block; color:var(--ink); font-size:13.5px; max-width:520px;
|
||||
margin:0 auto 8px;}
|
||||
.shot-file{display:block; color:var(--muted); font-size:12px;
|
||||
font-family:Consolas,monospace;}
|
||||
figcaption{color:var(--muted); font-size:12.5px; margin-top:6px; text-align:center;
|
||||
font-style:italic;}
|
||||
|
||||
/* Cover */
|
||||
.cover{min-height:92vh; display:flex; flex-direction:column; justify-content:center;
|
||||
text-align:center; page-break-after:always;}
|
||||
.cover .kicker{color:var(--accent); font-weight:700; letter-spacing:.14em;
|
||||
text-transform:uppercase; font-size:13px;}
|
||||
.cover h1{font-size:40px; margin:14px 0 6px;}
|
||||
.cover .sub{color:var(--muted); font-size:18px; max-width:560px; margin:0 auto;}
|
||||
.cover .meta{margin-top:36px; color:var(--muted); font-size:14px;}
|
||||
.cover .badge{display:inline-block; border:1px solid var(--line); border-radius:20px;
|
||||
padding:5px 14px; margin:4px; font-size:13px;}
|
||||
.print-note{background:var(--warn); border:1px solid var(--warn-line);
|
||||
border-radius:8px; padding:12px 16px; margin:26px auto 0; max-width:560px;
|
||||
font-size:13px; color:#7a5200; text-align:left;}
|
||||
|
||||
/* TOC */
|
||||
.toc-page{page-break-after:always;}
|
||||
.toc-page h2{font-size:24px; border-bottom:2px solid var(--accent);
|
||||
padding-bottom:8px; margin-bottom:8px;}
|
||||
ul.toc{list-style:none; margin:14px 0 0; padding:0;}
|
||||
ul.toc li{margin:0;}
|
||||
ul.toc a{display:block; padding:5px 0; border-bottom:1px dotted var(--line);}
|
||||
li.toc-1 a{font-weight:600; color:var(--ink); font-size:15px;}
|
||||
li.toc-2 a{padding-left:22px; color:var(--muted); font-size:13.5px;
|
||||
border-bottom:none;}
|
||||
|
||||
@page{
|
||||
size:A4; margin:20mm 16mm 18mm;
|
||||
@bottom-center{content:"Motion Core Character Controller — Page " counter(page);
|
||||
font-family:"Segoe UI",Arial,sans-serif; font-size:10px; color:#8a94a6;}
|
||||
}
|
||||
@media print{
|
||||
.page{max-width:none; padding:0;}
|
||||
.toc-hint{display:none;}
|
||||
a{color:var(--ink);}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
|
||||
<section class="cover">
|
||||
<div class="kicker">Unity Asset Store · User Manual</div>
|
||||
<h1>Motion Core Character Controller</h1>
|
||||
<p class="sub">Core locomotion motor and optional first-person add-on for Unity 6.</p>
|
||||
<div class="meta">
|
||||
<div>
|
||||
<span class="badge">Version 1.0.0</span>
|
||||
<span class="badge">Unity 6000.0+</span>
|
||||
<span class="badge">Input System</span>
|
||||
</div>
|
||||
<p style="margin-top:18px;">The Coder Guy</p>
|
||||
</div>
|
||||
<div class="print-note">
|
||||
<strong>To create a PDF:</strong> open this file in any web browser, choose
|
||||
<em>Print</em>, then <em>Save as PDF</em>. Page numbers appear in the footer
|
||||
of every page automatically. The blue dashed boxes are screenshot slots — drop
|
||||
annotated PNGs into the <code>Documentation/images/</code> folder using the
|
||||
file names shown, and they replace the placeholders automatically.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="toc-page">
|
||||
<h2>Table of Contents</h2>
|
||||
<p class="toc-hint" style="color:#8a94a6;font-size:13px;">
|
||||
Section numbers match the headings throughout this manual. When printed,
|
||||
each page is numbered in the footer.</p>
|
||||
<ul class='toc'><li class="toc-1"><a href="#1-requirements">1. Requirements</a></li>
|
||||
<li class="toc-1"><a href="#2-fast-setup">2. Fast Setup</a></li>
|
||||
<li class="toc-1"><a href="#3-demo-scenes">3. Demo Scenes</a></li>
|
||||
<li class="toc-1"><a href="#4-required-player-components">4. Required Player Components</a></li>
|
||||
<li class="toc-2"><a href="#rigidbody">Rigidbody</a></li>
|
||||
<li class="toc-2"><a href="#capsulecollider">CapsuleCollider</a></li>
|
||||
<li class="toc-2"><a href="#inputhandler">InputHandler</a></li>
|
||||
<li class="toc-2"><a href="#playercontroller">PlayerController</a></li>
|
||||
<li class="toc-1"><a href="#5-editor-validation">5. Editor Validation</a></li>
|
||||
<li class="toc-1"><a href="#6-movement-presets-and-tuning">6. Movement Presets and Tuning</a></li>
|
||||
<li class="toc-1"><a href="#7-camera-setup">7. Camera Setup</a></li>
|
||||
<li class="toc-2"><a href="#built-in-camerafollow">Built-In CameraFollow</a></li>
|
||||
<li class="toc-2"><a href="#optional-cinemachine">Optional Cinemachine</a></li>
|
||||
<li class="toc-1"><a href="#8-animation-integration">8. Animation Integration</a></li>
|
||||
<li class="toc-1"><a href="#9-input-buffering-and-action-priority">9. Input Buffering and Action Priority</a></li>
|
||||
<li class="toc-1"><a href="#10-moving-platforms">10. Moving Platforms</a></li>
|
||||
<li class="toc-1"><a href="#11-stable-public-api">11. Stable Public API</a></li>
|
||||
<li class="toc-1"><a href="#12-extension-patterns">12. Extension Patterns</a></li>
|
||||
<li class="toc-2"><a href="#skillmodule">SkillModule</a></li>
|
||||
<li class="toc-2"><a href="#inputextensionmodule">InputExtensionModule</a></li>
|
||||
<li class="toc-1"><a href="#13-fps-add-on-setup">13. FPS Add-On Setup</a></li>
|
||||
<li class="toc-1"><a href="#14-fps-systems">14. FPS Systems</a></li>
|
||||
<li class="toc-2"><a href="#weapons">Weapons</a></li>
|
||||
<li class="toc-2"><a href="#ads">ADS</a></li>
|
||||
<li class="toc-2"><a href="#recoil">Recoil</a></li>
|
||||
<li class="toc-2"><a href="#weapon-sway">Weapon Sway</a></li>
|
||||
<li class="toc-2"><a href="#damage">Damage</a></li>
|
||||
<li class="toc-2"><a href="#interaction">Interaction</a></li>
|
||||
<li class="toc-2"><a href="#inventory">Inventory</a></li>
|
||||
<li class="toc-2"><a href="#footsteps-and-surfaces">Footsteps And Surfaces</a></li>
|
||||
<li class="toc-2"><a href="#hitmarkers">Hitmarkers</a></li>
|
||||
<li class="toc-2"><a href="#projectiles">Projectiles</a></li>
|
||||
<li class="toc-2"><a href="#parkour">Parkour</a></li>
|
||||
<li class="toc-1"><a href="#15-fps-multiplayer-architecture">15. FPS Multiplayer Architecture</a></li>
|
||||
<li class="toc-1"><a href="#16-troubleshooting">16. Troubleshooting</a></li>
|
||||
<li class="toc-2"><a href="#character-does-not-move">Character Does Not Move</a></li>
|
||||
<li class="toc-2"><a href="#input-map-missing">Input Map Missing</a></li>
|
||||
<li class="toc-2"><a href="#bad-layer-masks">Bad Layer Masks</a></li>
|
||||
<li class="toc-2"><a href="#jitter-on-stairs">Jitter On Stairs</a></li>
|
||||
<li class="toc-2"><a href="#cannot-stand-from-crouch-or-prone">Cannot Stand From Crouch Or Prone</a></li>
|
||||
<li class="toc-2"><a href="#camera-not-rotating">Camera Not Rotating</a></li>
|
||||
<li class="toc-2"><a href="#fps-input-not-firing">FPS Input Not Firing</a></li>
|
||||
<li class="toc-2"><a href="#slides-do-not-start">Slides Do Not Start</a></li>
|
||||
<li class="toc-2"><a href="#jump-buffer-or-coyote-time-does-not-work">Jump Buffer Or Coyote Time Does Not Work</a></li>
|
||||
<li class="toc-2"><a href="#moving-platforms-slip-or-jitter">Moving Platforms Slip Or Jitter</a></li>
|
||||
<li class="toc-1"><a href="#17-migration-notes">17. Migration Notes</a></li>
|
||||
<li class="toc-1"><a href="#18-support-checklist">18. Support Checklist</a></li></ul>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<p>This is the single user manual for the Motion Core Character Controller package. Use this document to set up, use, tune, troubleshoot, and extend the Core controller and the optional FPS add-on.</p>
|
||||
<p>Package layout:</p>
|
||||
<pre><code>Assets/Character Controller/
|
||||
Core/
|
||||
FPSFirstPerson/</code></pre>
|
||||
<p>Core is standalone. The FPS add-on depends on Core.</p>
|
||||
<div class="callout"><div class="callout-title">Start here</div><p><strong>New here? Read this order:</strong> Section 1 (Requirements) → Section 2 (Fast Setup) → Section 3 (Demo Scenes). Those three get you a working, playable controller in a few minutes. Everything after that is reference material you can read as you need it.</p></div>
|
||||
<h2 id="1-requirements" class="sec">1. Requirements</h2>
|
||||
<ul>
|
||||
<li>Unity 6000.0 or newer.</li>
|
||||
<li>Unity Input System package.</li>
|
||||
<li>Unity UI package (<code>com.unity.ugui</code>) for demo HUD, validation UI, hitmarkers, and generated demo UI.</li>
|
||||
<li>A player GameObject with <code>Rigidbody</code>, <code>CapsuleCollider</code>, <code>InputHandler</code>, and <code>PlayerController</code>.</li>
|
||||
<li>Cinemachine is optional. <code>CharacterCinemachineAdapter</code> compiles without a Cinemachine assembly reference.</li>
|
||||
<li>TextMeshPro is optional and only used by optional debug labels.</li>
|
||||
</ul>
|
||||
<p>The controller uses Unity 6 physics APIs such as <code>Rigidbody.linearVelocity</code>.</p>
|
||||
<h2 id="2-fast-setup" class="sec">2. Fast Setup</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/setup-wizard.png" alt="The Setup Wizard (Tools > Character Controller > Setup Wizard). Highlight the Core/FPS toggle and the Create Controller button." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The Setup Wizard (Tools > Character Controller > Setup Wizard). Highlight the Core/FPS toggle and the Create Controller button.</span><span class="shot-file">images/setup-wizard.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 1. The Setup Wizard (Tools > Character Controller > Setup Wizard). Highlight the Core/FPS toggle and the Create Controller button.</figcaption>
|
||||
</figure>
|
||||
|
||||
<p>Use the setup wizard first. It is the recommended setup path for buyers.</p>
|
||||
<ol>
|
||||
<li>Import the asset.</li>
|
||||
<li>Install or enable Unity Input System and Unity UI.</li>
|
||||
<li>Open <code>Tools > Character Controller > Setup Wizard</code>.</li>
|
||||
<li>Choose <code>Core</code> or <code>FPS</code>.</li>
|
||||
<li>Press <code>Create Controller</code>, or disable <code>Create New Player</code> and assign an existing player.</li>
|
||||
<li>Press <code>Validate</code> from the wizard.</li>
|
||||
<li>Apply safe fixes if needed.</li>
|
||||
<li>Press Play.</li>
|
||||
</ol>
|
||||
<p>The wizard adds required components, assigns input assets, applies a motor preset, sets common Rigidbody/CapsuleCollider values, creates a camera rig when requested, and wires FPS components when <code>FPS</code> is selected.</p>
|
||||
<h2 id="3-demo-scenes" class="sec">3. Demo Scenes</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/core-demo-scene.png" alt="The Core demo scene in Play mode. Highlight the on-screen HUD and the 'Press F1' overlay hint." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The Core demo scene in Play mode. Highlight the on-screen HUD and the 'Press F1' overlay hint.</span><span class="shot-file">images/core-demo-scene.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 2. The Core demo scene in Play mode. Highlight the on-screen HUD and the 'Press F1' overlay hint.</figcaption>
|
||||
</figure>
|
||||
|
||||
<p>Menu items:</p>
|
||||
<ul>
|
||||
<li><code>Tools > Character Controller > Build Demo Scene</code></li>
|
||||
<li><code>Tools > Character Controller > Verify Core Demo Scene</code></li>
|
||||
<li><code>Tools > Character Controller > Build FPS Demo Scene</code></li>
|
||||
<li><code>Tools > Character Controller > Verify FPS Demo Scene</code></li>
|
||||
</ul>
|
||||
<p>Generated scenes:</p>
|
||||
<ul>
|
||||
<li>Core: <code>Assets/Character Controller/Core/Scenes/DemoScene.unity</code></li>
|
||||
<li>FPS: <code>Assets/Character Controller/FPSFirstPerson/Scenes/FPSDemoScene.unity</code></li>
|
||||
</ul>
|
||||
<p>The Core demo includes flat ground, stairs, walkable and steep slopes, uneven terrain, a low ceiling, a ledge/jump section, a moving platform, and an over-height step marker.</p>
|
||||
<p>The FPS demo includes weapon handling, ADS, recoil, weapon sway, interactions, targets, damage feedback, footsteps, surface detection, parkour, and a movement test gym.</p>
|
||||
<p>In the demos, press <code>F1</code> to hide/show HUD and debug overlays.</p>
|
||||
<h2 id="4-required-player-components" class="sec">4. Required Player Components</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/player-inspector.png" alt="The player GameObject Inspector. Highlight the Rigidbody, CapsuleCollider, InputHandler and PlayerController components." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The player GameObject Inspector. Highlight the Rigidbody, CapsuleCollider, InputHandler and PlayerController components.</span><span class="shot-file">images/player-inspector.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 3. The player GameObject Inspector. Highlight the Rigidbody, CapsuleCollider, InputHandler and PlayerController components.</figcaption>
|
||||
</figure>
|
||||
|
||||
<h3 id="rigidbody">Rigidbody</h3>
|
||||
<p>Recommended settings:</p>
|
||||
<ul>
|
||||
<li><code>Use Gravity</code>: enabled.</li>
|
||||
<li><code>Is Kinematic</code>: disabled.</li>
|
||||
<li><code>Freeze Rotation</code>: enabled.</li>
|
||||
<li><code>Interpolation</code>: <code>Interpolate</code>.</li>
|
||||
<li><code>Collision Detection</code>: <code>Continuous Dynamic</code> for fast FPS movement.</li>
|
||||
</ul>
|
||||
<p><code>PlayerController</code> applies important safety settings at startup, and the validation window can fix common Rigidbody mistakes before play mode.</p>
|
||||
<h3 id="capsulecollider">CapsuleCollider</h3>
|
||||
<p>Recommended starting values:</p>
|
||||
<ul>
|
||||
<li><code>Radius</code>: <code>0.3</code>.</li>
|
||||
<li><code>Height</code>: <code>1.8</code>.</li>
|
||||
<li><code>Center</code>: <code>(0, 0.9, 0)</code>.</li>
|
||||
<li><code>Direction</code>: Y axis.</li>
|
||||
</ul>
|
||||
<p>Use one main body collider on the player root. Put visual meshes, first-person arms, view models, and hitboxes on child objects.</p>
|
||||
<h3 id="inputhandler">InputHandler</h3>
|
||||
<p>Core serialized fields:</p>
|
||||
<ul>
|
||||
<li><code>Movement Actions Asset</code>: core <code>.inputactions</code> asset.</li>
|
||||
<li><code>Movement Action Map Name</code>: defaults to <code>Control</code>.</li>
|
||||
<li><code>Extension Action Assets</code>: optional add-on input assets, such as <code>FPSControls.inputactions</code>.</li>
|
||||
</ul>
|
||||
<p>Expected <code>Control</code> actions:</p>
|
||||
<ul>
|
||||
<li><code>Move</code>: <code>Vector2</code>.</li>
|
||||
<li><code>Jump</code>: button.</li>
|
||||
<li><code>Crouch</code>: button.</li>
|
||||
<li><code>Prone</code>: button.</li>
|
||||
<li><code>Dash</code>: button.</li>
|
||||
<li><code>Walk</code>: button.</li>
|
||||
<li><code>Sprint</code>: button.</li>
|
||||
</ul>
|
||||
<h3 id="playercontroller">PlayerController</h3>
|
||||
<p>Important serialized fields:</p>
|
||||
<ul>
|
||||
<li><code>Motor Settings</code>: optional <code>CharacterMotorSettings</code> preset. When assigned, it drives movement tuning.</li>
|
||||
<li><code>Speed</code>: target run speed.</li>
|
||||
<li><code>SprintSpeed</code>: target sprint speed. This is not added on top of <code>Speed</code>.</li>
|
||||
<li><code>WalkSpeed</code>, <code>CrouchSpeed</code>, <code>ProneSpeed</code>: target speeds for those modes.</li>
|
||||
<li><code>GroundAcceleration</code>, <code>GroundDeceleration</code>: grounded response.</li>
|
||||
<li><code>AirAcceleration</code>, <code>AirDeceleration</code>: air control.</li>
|
||||
<li><code>JumpingForce</code>, <code>CoyoteTime</code>, <code>JumpBufferTime</code>, <code>GravityScale</code>, <code>MaxFallSpeed</code>: jump and fall behavior.</li>
|
||||
<li><code>GroundLayerMask</code>, <code>StairsLayerMask</code>: surface detection layers.</li>
|
||||
<li><code>MaxSlopeAngle</code>, <code>MaxStairsAngle</code>: walkability limits.</li>
|
||||
<li><code>GroundSnapDistance</code>, <code>GroundStickForce</code>, <code>StepHeight</code>, <code>StepCheckDistance</code>, <code>StepProbeRadiusScale</code>: uneven terrain and stair behavior.</li>
|
||||
<li><code>CeilingCheckDistance</code>: clearance margin for standing from crouch or prone.</li>
|
||||
<li><code>UphillSlopeSpeedMultiplier</code>, <code>DownhillSlopeSpeedMultiplier</code>: slope speed modifiers.</li>
|
||||
</ul>
|
||||
<h2 id="5-editor-validation" class="sec">5. Editor Validation</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/validation-window.png" alt="The Validation Window after a passing check. Highlight the Validate button and the Apply Safe Fixes buttons." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The Validation Window after a passing check. Highlight the Validate button and the Apply Safe Fixes buttons.</span><span class="shot-file">images/validation-window.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 4. The Validation Window after a passing check. Highlight the Validate button and the Apply Safe Fixes buttons.</figcaption>
|
||||
</figure>
|
||||
|
||||
<p>Open <code>Tools > Character Controller > Validation Window</code>.</p>
|
||||
<p>The validator checks:</p>
|
||||
<ul>
|
||||
<li>Required player components: <code>PlayerController</code>, <code>Rigidbody</code>, <code>CapsuleCollider</code>, <code>InputHandler</code>.</li>
|
||||
<li>Rigidbody settings: non-kinematic, gravity enabled, rotation frozen, interpolation enabled, continuous collision recommended.</li>
|
||||
<li>Capsule dimensions: positive radius/height, height at least twice the radius, valid stance heights.</li>
|
||||
<li>Core input: movement asset assigned, <code>Control</code> map exists, required actions exist.</li>
|
||||
<li>Layer masks: <code>GroundLayerMask</code> and <code>StairsLayerMask</code> are not empty.</li>
|
||||
<li>FPS input: when FPS components are present, an extension input asset with the <code>FPS</code> map and expected actions is assigned.</li>
|
||||
</ul>
|
||||
<p>Safe fix buttons can:</p>
|
||||
<ul>
|
||||
<li>Add missing required components.</li>
|
||||
<li>Assign same-object component references.</li>
|
||||
<li>Apply recommended Rigidbody defaults.</li>
|
||||
<li>Set empty ground/stair masks to <code>Default</code>.</li>
|
||||
<li>Assign the included core input asset.</li>
|
||||
<li>Add the included FPS input asset when the FPS extension is present.</li>
|
||||
</ul>
|
||||
<p>The validator does not guess project-specific layer names, custom action map names, or final movement tuning.</p>
|
||||
<h2 id="6-movement-presets-and-tuning" class="sec">6. Movement Presets and Tuning</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/motor-settings.png" alt="The PlayerController Inspector. Highlight the Motor Settings field with a preset assigned." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The PlayerController Inspector. Highlight the Motor Settings field with a preset assigned.</span><span class="shot-file">images/motor-settings.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 5. The PlayerController Inspector. Highlight the Motor Settings field with a preset assigned.</figcaption>
|
||||
</figure>
|
||||
|
||||
<p>Included presets live in <code>Assets/Character Controller/Core/Data</code>:</p>
|
||||
<ul>
|
||||
<li><code>TacticalFPSMotorSettings</code>: grounded, responsive FPS baseline.</li>
|
||||
<li><code>ArcadeFPSMotorSettings</code>: faster and more forgiving.</li>
|
||||
<li><code>ThirdPersonRPGMotorSettings</code>: slower, animation-friendly movement.</li>
|
||||
<li><code>ParkourLiteMotorSettings</code>: faster air control and traversal-friendly movement.</li>
|
||||
</ul>
|
||||
<p>Assign one asset to <code>PlayerController -> Motor Settings</code> to swap movement feel. Duplicate a preset before editing project-specific values.</p>
|
||||
<p>Speed fields:</p>
|
||||
<ul>
|
||||
<li><code>RunSpeed</code>: normal movement target.</li>
|
||||
<li><code>SprintSpeed</code>: sprint movement target, not an additive bonus.</li>
|
||||
<li><code>WalkSpeed</code>: precise movement target.</li>
|
||||
<li><code>CrouchSpeed</code>: crouched movement target.</li>
|
||||
<li><code>ProneSpeed</code>: prone movement target.</li>
|
||||
</ul>
|
||||
<p>Keep speeds in this order for readable tuning:</p>
|
||||
<pre><code>ProneSpeed < CrouchSpeed <= WalkSpeed < RunSpeed < SprintSpeed</code></pre>
|
||||
<p>Acceleration fields:</p>
|
||||
<ul>
|
||||
<li><code>GroundAcceleration</code>: how quickly grounded movement reaches target speed.</li>
|
||||
<li><code>GroundDeceleration</code>: how quickly the controller slows when input stops or target speed drops.</li>
|
||||
<li><code>AirAcceleration</code>: air steering strength.</li>
|
||||
<li><code>AirDeceleration</code>: planar speed bleed-off while airborne.</li>
|
||||
</ul>
|
||||
<p>Jump and fall fields:</p>
|
||||
<ul>
|
||||
<li><code>JumpingForce</code>: upward jump velocity.</li>
|
||||
<li><code>CanMoveWhileJumping</code>: enables air control.</li>
|
||||
<li><code>CoyoteTime</code>: grace time after leaving ground.</li>
|
||||
<li><code>JumpBufferTime</code>: time a jump input remains valid before landing.</li>
|
||||
<li><code>ParkourBufferTime</code>: time a parkour intent remains valid.</li>
|
||||
<li><code>GravityScale</code>: extra gravity multiplier through Rigidbody force.</li>
|
||||
<li><code>MaxFallSpeed</code>: downward velocity clamp.</li>
|
||||
</ul>
|
||||
<p>Ground, stairs, and slopes:</p>
|
||||
<ul>
|
||||
<li><code>MaxSlopeAngle</code>: highest ordinary ground angle considered walkable.</li>
|
||||
<li><code>MaxStairsAngle</code>: highest stair angle considered walkable.</li>
|
||||
<li><code>GroundProbeRadiusScale</code>: ground cast radius relative to capsule radius.</li>
|
||||
<li><code>GroundSnapDistance</code>: distance used to snap back to nearby walkable ground.</li>
|
||||
<li><code>GroundStickForce</code>: downward force while grounded.</li>
|
||||
<li><code>StepHeight</code>: maximum climbable step height.</li>
|
||||
<li><code>StepCheckDistance</code>: forward distance for step checks.</li>
|
||||
<li><code>StepProbeRadiusScale</code>: step probe radius relative to capsule radius.</li>
|
||||
<li><code>CeilingCheckDistance</code>: extra clearance required before standing.</li>
|
||||
<li><code>UphillSlopeSpeedMultiplier</code>: speed modifier when moving uphill.</li>
|
||||
<li><code>DownhillSlopeSpeedMultiplier</code>: speed modifier when moving downhill.</li>
|
||||
</ul>
|
||||
<p>Recommended tuning order:</p>
|
||||
<ol>
|
||||
<li>Set <code>GroundLayerMask</code> and <code>StairsLayerMask</code>.</li>
|
||||
<li>Set capsule radius and height.</li>
|
||||
<li>Tune <code>StepHeight</code> to match stair geometry.</li>
|
||||
<li>Increase <code>GroundSnapDistance</code> only enough to remove small ledge flicker.</li>
|
||||
<li>Increase <code>GroundStickForce</code> only enough to keep stable contact.</li>
|
||||
<li>Tune acceleration and deceleration.</li>
|
||||
<li>Tune jump/fall.</li>
|
||||
<li>Tune slope speed multipliers last.</li>
|
||||
</ol>
|
||||
<p>Slide fields:</p>
|
||||
<ul>
|
||||
<li><code>SlideDuration</code>: slide lifetime.</li>
|
||||
<li><code>SlideStartSpeed</code>: starting slide velocity.</li>
|
||||
<li><code>SlideEndSpeed</code>: minimum ending velocity.</li>
|
||||
<li><code>SlideSteeringStrength</code>: steering control during slide.</li>
|
||||
<li><code>SlideCooldownDuration</code>: time before another slide.</li>
|
||||
<li><code>MinimumSlideInputSpeed</code>: required planar speed before sprint+crouch can become slide.</li>
|
||||
</ul>
|
||||
<p>External force field:</p>
|
||||
<ul>
|
||||
<li><code>ExternalForceDrag</code>: decay rate for external velocity.</li>
|
||||
</ul>
|
||||
<p>Use <code>PlayerController.AddImpulse</code> for impacts, explosions, launch pads, or weapon knockback. Use <code>SetVelocity</code> for authoritative corrections.</p>
|
||||
<h2 id="7-camera-setup" class="sec">7. Camera Setup</h2>
|
||||
<h3 id="built-in-camerafollow">Built-In CameraFollow</h3>
|
||||
<p>Add <code>CameraFollow</code> to a camera and assign the player transform as <code>Target</code>. It supports orbiting, shoulder offset, collision, lock-on influence, and auto-follow yaw.</p>
|
||||
<p><code>CameraFollow</code> calls <code>PlayerController.SetMainCameraTransform</code>, which makes movement camera-relative.</p>
|
||||
<h3 id="optional-cinemachine">Optional Cinemachine</h3>
|
||||
<p>Use <code>CharacterCinemachineAdapter</code> when your project uses Cinemachine.</p>
|
||||
<ol>
|
||||
<li>Install Cinemachine from Package Manager.</li>
|
||||
<li>Create your Cinemachine camera rig.</li>
|
||||
<li>Add <code>CharacterCinemachineAdapter</code>, or start from <code>Assets/Character Controller/Core/prefabs/CinemachineAdapterRig.prefab</code>.</li>
|
||||
<li>Assign:</li>
|
||||
</ol>
|
||||
<ul>
|
||||
<li><code>Player Controller</code></li>
|
||||
<li><code>Cinemachine Camera</code></li>
|
||||
<li><code>Follow Target</code></li>
|
||||
<li><code>Look At Target</code></li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>Keep <code>Assign Player Camera Reference</code> enabled.</li>
|
||||
</ol>
|
||||
<p>The adapter stores the Cinemachine reference as a plain <code>Component</code> and uses reflection. Core still imports without Cinemachine installed.</p>
|
||||
<p>For FPS gameplay, prefer <code>FpsCameraController</code>. Cinemachine is better suited for spectators, cutscenes, kill cams, or third-person modes.</p>
|
||||
<h2 id="8-animation-integration" class="sec">8. Animation Integration</h2>
|
||||
<p>Animation is optional. The controller works without an <code>Animator</code>.</p>
|
||||
<p>To connect your own Animator Controller:</p>
|
||||
<ol>
|
||||
<li>Add <code>CharacterAnimatorBridge</code> to the same GameObject as <code>PlayerController</code>.</li>
|
||||
<li>Assign an <code>Animator</code>, or leave it blank so the bridge searches children.</li>
|
||||
<li>Assign a <code>CharacterAnimatorParameters</code> asset.</li>
|
||||
<li>Match your Animator Controller parameter names to the mapping asset.</li>
|
||||
</ol>
|
||||
<p>Default parameters:</p>
|
||||
<ul>
|
||||
<li>Float: <code>Speed</code>, <code>PlanarSpeed</code>, <code>Forward</code>, <code>Strafe</code>.</li>
|
||||
<li>Bool: <code>IsGrounded</code>, <code>IsFalling</code>, <code>IsJumping</code>, <code>IsSprinting</code>, <code>IsCrouching</code>, <code>IsProne</code>, <code>IsSliding</code>.</li>
|
||||
<li>Int: <code>Stance</code>, <code>MovementState</code>.</li>
|
||||
<li>Trigger: <code>JumpStarted</code>, <code>Landed</code>, <code>SlideStarted</code>, <code>SlideEnded</code>, <code>VaultStarted</code>, <code>VaultEnded</code>, <code>MantleStarted</code>, <code>MantleEnded</code>.</li>
|
||||
</ul>
|
||||
<p>Blank parameter names are ignored. Missing Animator parameters are ignored, so partial integrations are safe.</p>
|
||||
<p><code>Stance</code> values:</p>
|
||||
<ul>
|
||||
<li><code>0</code>: Standing.</li>
|
||||
<li><code>1</code>: Crouching.</li>
|
||||
<li><code>2</code>: Prone.</li>
|
||||
</ul>
|
||||
<p><code>MovementState</code> values:</p>
|
||||
<ul>
|
||||
<li><code>0</code>: None.</li>
|
||||
<li><code>1</code>: Idle.</li>
|
||||
<li><code>2</code>: Moving.</li>
|
||||
<li><code>3</code>: Jumping.</li>
|
||||
<li><code>4</code>: Falling.</li>
|
||||
<li><code>5</code>: Crouching.</li>
|
||||
<li><code>6</code>: Prone.</li>
|
||||
<li><code>7</code>: Sliding.</li>
|
||||
<li><code>8</code>: Dashing.</li>
|
||||
<li><code>9</code>: Vaulting.</li>
|
||||
<li><code>10</code>: Parkour.</li>
|
||||
</ul>
|
||||
<p>The bridge exposes events for jump, land, slide, vault, mantle, and stance changes. Use those events for animation events, IK, audio, VFX, or camera effects without editing movement states.</p>
|
||||
<p>The FPS demo builder creates simple demo clips for idle, crouch, prone, and ground slide. They animate a generated capsule body only and are integration examples, not final character art.</p>
|
||||
<h2 id="9-input-buffering-and-action-priority" class="sec">9. Input Buffering and Action Priority</h2>
|
||||
<p>The controller resolves short-lived action input through <code>PlayerController</code> buffers.</p>
|
||||
<p>Built-in priority rules:</p>
|
||||
<ol>
|
||||
<li>FPS parkour modules get first chance to consume jump intent during <code>Update</code>.</li>
|
||||
<li>Core vault gets the next chance when a valid vault target exists.</li>
|
||||
<li>Grounded or coyote-time jump runs when no valid parkour action consumed the intent.</li>
|
||||
<li>Buffered landing jump runs when jump is pressed shortly before landing.</li>
|
||||
<li>Extra jumps from <code>DoubleJumpModule</code> run only after grounded and coyote-time jumps are no longer valid.</li>
|
||||
<li>Crouch while sprinting starts a slide only when <code>CanStartSlide()</code> is valid. Otherwise it becomes crouch.</li>
|
||||
<li>Prone has priority over held crouch in continuous stance input.</li>
|
||||
<li>Interaction commands do not change locomotion state by default. Interaction systems should request movement locks or state changes explicitly.</li>
|
||||
</ol>
|
||||
<p>Public buffer API:</p>
|
||||
<pre><code>playerController.BufferJumpIntent();
|
||||
playerController.BufferParkourIntent();
|
||||
|
||||
bool hasJump = playerController.HasBufferedJumpIntent;
|
||||
bool hasParkour = playerController.HasBufferedParkourIntent;
|
||||
|
||||
bool consumedJump = playerController.TryConsumeBufferedJumpIntent();
|
||||
bool consumedParkour = playerController.TryConsumeBufferedParkourIntent();
|
||||
|
||||
playerController.ClearBufferedInputs();</code></pre>
|
||||
<p>For custom buffered actions:</p>
|
||||
<ol>
|
||||
<li>Buffer input once from your input adapter or command sink.</li>
|
||||
<li>Resolve it from one owner system in <code>UpdateModule</code> or <code>FixedUpdateModule</code>.</li>
|
||||
<li>Check action-specific conditions before consuming the buffer.</li>
|
||||
<li>Consume and clear only when the action actually starts.</li>
|
||||
<li>Avoid direct state-level input subscriptions for actions that compete with jump, parkour, crouch, prone, slide, or interaction.</li>
|
||||
</ol>
|
||||
<h2 id="10-moving-platforms" class="sec">10. Moving Platforms</h2>
|
||||
<p>Add <code>MovingPlatform</code> to moving or rotating platforms. It supports Rigidbody platforms and scripted transform platforms. The controller tracks platform transform deltas and preserves inherited velocity when jumping from platforms.</p>
|
||||
<p>Custom platforms can implement <code>IMovingPlatform</code>:</p>
|
||||
<pre><code>public interface IMovingPlatform
|
||||
{
|
||||
Transform PlatformTransform { get; }
|
||||
Vector3 LinearVelocity { get; }
|
||||
Vector3 AngularVelocity { get; }
|
||||
Vector3 GetVelocityAtPoint(Vector3 worldPoint);
|
||||
}</code></pre>
|
||||
<p>For Rigidbody platforms, <code>MovingPlatform</code> can use <code>Rigidbody.GetPointVelocity</code>. For scripted platforms, it derives velocity from fixed-step transform deltas.</p>
|
||||
<h2 id="11-stable-public-api" class="sec">11. Stable Public API</h2>
|
||||
<p>Use public APIs instead of private fields.</p>
|
||||
<p>State:</p>
|
||||
<ul>
|
||||
<li><code>StateSnapshot</code></li>
|
||||
<li><code>GetStateSnapshot()</code></li>
|
||||
<li><code>CurrentStateName</code></li>
|
||||
<li><code>CurrentStateType</code></li>
|
||||
<li><code>Stance</code></li>
|
||||
<li><code>Grounded</code></li>
|
||||
<li><code>Velocity</code></li>
|
||||
<li><code>PlanarVelocity</code></li>
|
||||
<li><code>SpeedMode</code></li>
|
||||
<li><code>SlopeAngle</code></li>
|
||||
<li><code>HasSurfaceHit</code></li>
|
||||
<li><code>SurfaceHit</code></li>
|
||||
<li><code>Platform</code></li>
|
||||
</ul>
|
||||
<p>Control gates:</p>
|
||||
<ul>
|
||||
<li><code>SetMovementEnabled(bool)</code></li>
|
||||
<li><code>SetLookEnabled(bool)</code></li>
|
||||
<li><code>SetMovementFacingEnabled(bool)</code></li>
|
||||
<li><code>SetSlopeAlignmentEnabled(bool)</code></li>
|
||||
<li><code>SetGroundProbingEnabled(bool)</code></li>
|
||||
</ul>
|
||||
<p>Motion and actions:</p>
|
||||
<ul>
|
||||
<li><code>AddImpulse(Vector3 impulse, ForceMode forceMode = ForceMode.VelocityChange)</code></li>
|
||||
<li><code>SetVelocity(Vector3 velocity)</code></li>
|
||||
<li><code>Teleport(Vector3 position)</code></li>
|
||||
<li><code>Teleport(Vector3 position, Quaternion rotation)</code></li>
|
||||
<li><code>TryJump()</code></li>
|
||||
<li><code>TryStartSlide()</code></li>
|
||||
<li><code>TryStartVault()</code></li>
|
||||
<li><code>ForceStance(PlayerStance stance)</code></li>
|
||||
<li><code>ClearBufferedInputs()</code></li>
|
||||
</ul>
|
||||
<p><code>CharacterSpeedMode</code> covers idle, walk, run, sprint, crouch, prone, slide, air, dash, vault, and parkour.</p>
|
||||
<p>Custom scripted parkour states should implement <code>ICharacterParkourState</code> so state snapshots and animation bridge report parkour without relying on class-name conventions.</p>
|
||||
<h2 id="12-extension-patterns" class="sec">12. Extension Patterns</h2>
|
||||
<h3 id="skillmodule">SkillModule</h3>
|
||||
<p>Use <code>SkillModule</code> for gameplay features that run alongside core states.</p>
|
||||
<pre><code>public class MySkill : SkillModule
|
||||
{
|
||||
protected override void OnInitialize() {}
|
||||
protected override void OnCleanup() {}
|
||||
public override void UpdateModule(float deltaTime) {}
|
||||
public override void FixedUpdateModule(float deltaTime) {}
|
||||
}</code></pre>
|
||||
<h3 id="inputextensionmodule">InputExtensionModule</h3>
|
||||
<p>Use <code>InputExtensionModule</code> to read additional action maps from <code>InputHandler</code> assets.</p>
|
||||
<pre><code>public class MyInputExtension : InputExtensionModule
|
||||
{
|
||||
protected override void OnActionsEnabled() {}
|
||||
protected override void OnActionsDisabled() {}
|
||||
}</code></pre>
|
||||
<p>Add-on packages may depend on Core. Core should not depend on add-ons.</p>
|
||||
<h2 id="13-fps-add-on-setup" class="sec">13. FPS Add-On Setup</h2>
|
||||
<figure class="shot">
|
||||
<div class="shot-frame">
|
||||
<img src="images/fps-wizard.png" alt="The Setup Wizard with FPS selected. Highlight the FPS toggle and the Assign Demo Rifle checkbox." onerror="this.closest('.shot-frame').classList.add('missing');this.remove();">
|
||||
<div class="shot-slot"><span class="shot-tag">SCREENSHOT SLOT</span><span class="shot-cap">Capture: The Setup Wizard with FPS selected. Highlight the FPS toggle and the Assign Demo Rifle checkbox.</span><span class="shot-file">images/fps-wizard.png</span></div>
|
||||
</div>
|
||||
<figcaption>Figure 6. The Setup Wizard with FPS selected. Highlight the FPS toggle and the Assign Demo Rifle checkbox.</figcaption>
|
||||
</figure>
|
||||
|
||||
<p>Fast path:</p>
|
||||
<ol>
|
||||
<li>Open <code>Tools > Character Controller > Setup Wizard</code>.</li>
|
||||
<li>Choose <code>FPS</code>.</li>
|
||||
<li>Press <code>Create Controller</code>, or configure an existing player.</li>
|
||||
<li>Leave <code>Assign Demo Rifle</code> enabled for a first working setup.</li>
|
||||
<li>Press <code>Validate</code>.</li>
|
||||
<li>Press Play.</li>
|
||||
</ol>
|
||||
<p>Manual requirements:</p>
|
||||
<ul>
|
||||
<li><code>FPSModule</code> on the same GameObject as <code>PlayerController</code>.</li>
|
||||
<li><code>FPSControls.inputactions</code> in <code>InputHandler -> Extension Action Assets</code>.</li>
|
||||
<li><code>FpsLocalInputCommandSource</code> enabled on local player objects.</li>
|
||||
<li><code>FpsCameraController</code>, <code>WeaponManager</code>, <code>FPSViewMotion</code>, <code>AdsController</code>, <code>RecoilController</code>, <code>WeaponSwayController</code>, and any desired FPS systems.</li>
|
||||
</ul>
|
||||
<p>Expected <code>FPS</code> actions:</p>
|
||||
<ul>
|
||||
<li><code>Look</code></li>
|
||||
<li><code>Fire</code></li>
|
||||
<li><code>Aim</code></li>
|
||||
<li><code>Reload</code></li>
|
||||
<li><code>Melee</code></li>
|
||||
<li><code>Use</code></li>
|
||||
<li><code>Weapon1</code></li>
|
||||
<li><code>Weapon2</code></li>
|
||||
<li><code>Weapon3</code></li>
|
||||
<li><code>Weapon4</code></li>
|
||||
</ul>
|
||||
<p>The FPS wizard wires the command bus, camera, view motion, ADS, recoil, weapon sway, weapon manager, interaction, inventory, footsteps, hitmarker feedback, parkour, and <code>FPSModule</code>.</p>
|
||||
<h2 id="14-fps-systems" class="sec">14. FPS Systems</h2>
|
||||
<h3 id="weapons">Weapons</h3>
|
||||
<p>Create weapon assets from <code>Create > Character Controller > FPS > Weapon Definition</code>.</p>
|
||||
<p>Important systems:</p>
|
||||
<ul>
|
||||
<li><code>WeaponDefinition</code>: ScriptableObject weapon setup for hitscan or projectile weapons.</li>
|
||||
<li><code>WeaponManager</code>: loadout, weapon switching, view-model spawning, ADS FOV, and weapon events.</li>
|
||||
<li><code>Weapon</code>: base class for fire-rate, semi/burst/full-auto, ammo, and reload behavior.</li>
|
||||
<li><code>IWeaponModifier</code>: attachment-friendly stat hook.</li>
|
||||
<li><code>WeaponStateSnapshot</code>: small state packet for UI, save data, or multiplayer replication.</li>
|
||||
</ul>
|
||||
<h3 id="ads">ADS</h3>
|
||||
<p><code>WeaponDefinition</code> implements <code>IAdsProvider</code>. Each weapon can define multiple <code>AdsSightDefinition</code> entries for iron sights, optics, scopes, or alternate sight positions.</p>
|
||||
<p>Useful callbacks:</p>
|
||||
<ul>
|
||||
<li><code>AimStarted</code></li>
|
||||
<li><code>AimCanceled</code></li>
|
||||
<li><code>FullyAimed</code></li>
|
||||
<li><code>AimWeightChanged</code></li>
|
||||
<li><code>SightChanged</code></li>
|
||||
</ul>
|
||||
<h3 id="recoil">Recoil</h3>
|
||||
<p>Create recoil profiles from <code>Create > Character Controller > FPS > Recoil Profile</code>.</p>
|
||||
<p>Profiles support:</p>
|
||||
<ul>
|
||||
<li>Camera vertical, horizontal, and roll kick.</li>
|
||||
<li>Weapon position and rotation kick.</li>
|
||||
<li>Recovery delay and speed.</li>
|
||||
<li>Kick snappiness.</li>
|
||||
<li>Randomization curves.</li>
|
||||
<li>Burst accumulation curves.</li>
|
||||
<li>Per-axis weapon-position recoil limits.</li>
|
||||
</ul>
|
||||
<p><code>RecoilController</code> applies recoil through camera and weapon-view offsets, so weapon firing code stays independent from recoil behavior.</p>
|
||||
<h3 id="weapon-sway">Weapon Sway</h3>
|
||||
<p>Create sway profiles from <code>Create > Character Controller > FPS > Weapon Sway Profile</code>.</p>
|
||||
<p>Sway sources:</p>
|
||||
<ul>
|
||||
<li><code>MouseMovementSwaySource</code></li>
|
||||
<li><code>MovementSwaySource</code></li>
|
||||
<li><code>IdleBreathingSwaySource</code></li>
|
||||
<li><code>SprintSwaySource</code></li>
|
||||
</ul>
|
||||
<p><code>WeaponSwayProfile</code> exposes curves and amplitudes per source, ADS reduction, and smoothing. Weapon sway and camera bob can be tuned or disabled independently.</p>
|
||||
<h3 id="damage">Damage</h3>
|
||||
<p>Use <code>HealthComponent</code> on players, NPCs, or destructibles. Add <code>DamageHitbox</code> to child colliders for head, torso, limb, armor, or weak-point routing.</p>
|
||||
<p>Included modifier examples:</p>
|
||||
<ul>
|
||||
<li><code>DamageMultiplierModifier</code></li>
|
||||
<li><code>CriticalDamageModifier</code></li>
|
||||
<li><code>HitGroupDamageModifier</code></li>
|
||||
</ul>
|
||||
<p>Damage payloads and snapshots are designed for multiplayer-friendly replication.</p>
|
||||
<h3 id="interaction">Interaction</h3>
|
||||
<p><code>FpsInteractor</code> raycasts from the FPS camera and talks only to <code>IInteractable</code> and <code>IHoldInteractable</code>.</p>
|
||||
<p>Useful events:</p>
|
||||
<ul>
|
||||
<li><code>FocusChanged</code></li>
|
||||
<li><code>PromptChanged</code></li>
|
||||
<li><code>HoldStarted</code></li>
|
||||
<li><code>HoldProgressChanged</code></li>
|
||||
<li><code>HoldCanceled</code></li>
|
||||
<li><code>InteractionCompleted</code></li>
|
||||
</ul>
|
||||
<p>Use <code>IInteractionCondition</code> components for rules such as distance, locked state, inventory keys, quest state, faction, or authority checks.</p>
|
||||
<h3 id="inventory">Inventory</h3>
|
||||
<p>Create item assets from <code>Create > Character Controller > FPS > Inventory</code>.</p>
|
||||
<p><code>FpsInventory</code> supports stackable items, ammo counts, weapon items, equipment slots, and quick access slots. <code>InventoryWeaponLoadoutBinder</code> can rebuild the <code>WeaponManager</code> loadout from equipped <code>WeaponItemDefinition</code> assets.</p>
|
||||
<h3 id="footsteps-and-surfaces">Footsteps And Surfaces</h3>
|
||||
<p>Create surface assets from <code>Create > Character Controller > FPS > Surface Profile</code>. Add <code>SurfaceIdentifier</code> to surfaces or configure <code>SurfaceDetector</code> layer mappings.</p>
|
||||
<p><code>FootstepController</code> emits walking, running, and crouching footsteps. <code>IFootstepEffectReceiver</code> is available for custom VFX, decals, or dust.</p>
|
||||
<h3 id="hitmarkers">Hitmarkers</h3>
|
||||
<p>Create a hitmarker profile from <code>Create > Character Controller > FPS > Hitmarker Settings</code>.</p>
|
||||
<p>Use:</p>
|
||||
<ul>
|
||||
<li><code>HitmarkerFeedbackController</code></li>
|
||||
<li><code>HitmarkerCanvasView</code></li>
|
||||
<li><code>HitmarkerSettings</code></li>
|
||||
</ul>
|
||||
<p>Damage confirmations are published by <code>HealthComponent</code> through <code>DamageEventBus</code>, so hitmarkers are not coupled to guns or projectiles.</p>
|
||||
<h3 id="projectiles">Projectiles</h3>
|
||||
<p>Create projectile tuning assets from <code>Create > Character Controller > FPS > Projectile Ballistics Profile</code>.</p>
|
||||
<p>Projectile features:</p>
|
||||
<ul>
|
||||
<li>Bullet travel over time.</li>
|
||||
<li>Bullet drop through gravity scale.</li>
|
||||
<li>Drag.</li>
|
||||
<li>Penetration.</li>
|
||||
<li>Ricochet.</li>
|
||||
<li>Surface-specific impact effects.</li>
|
||||
<li>Non-alloc swept casts.</li>
|
||||
</ul>
|
||||
<h3 id="parkour">Parkour</h3>
|
||||
<p>Create parkour tuning assets from <code>Create > Character Controller > FPS > Parkour Settings</code>.</p>
|
||||
<p>Supported mechanics:</p>
|
||||
<ul>
|
||||
<li>Mantling from jump intent near taller ledges.</li>
|
||||
<li>Vaulting from jump intent near low obstacles.</li>
|
||||
<li>Wall running while airborne, sprinting, moving fast enough, recently pressing jump, having enough ground clearance, and moving along a valid side wall.</li>
|
||||
<li>Ledge grabbing while airborne, jump to climb, crouch to drop.</li>
|
||||
</ul>
|
||||
<p>Wall running intentionally does not trigger from a head-on jump into a wall. By default it requires recent jump intent, enough starting height above walkable ground, forward/sprint input, side-wall alignment, and movement along the wall. If conditions fail, the controller falls normally and does not keep the player attached to the wall.</p>
|
||||
<p>During active wall-run, <code>WallRunControlledDownwardSpeed</code> controls downward velocity. The run ends when the player releases required input, looks or moves away from the wall direction, reaches walkable ground, loses the wall, or reaches <code>WallRunDuration</code>.</p>
|
||||
<h2 id="15-fps-multiplayer-architecture" class="sec">15. FPS Multiplayer Architecture</h2>
|
||||
<p>The FPS add-on is networking-ready but transport-free. It does not depend on Netcode for GameObjects, FishNet, Mirror, Photon, or any networking package.</p>
|
||||
<p>Command flow:</p>
|
||||
<ul>
|
||||
<li><code>FpsLocalInputCommandSource</code> converts local input to <code>FpsPlayerCommand</code>.</li>
|
||||
<li>Gameplay systems implement <code>IFpsCommandSink</code>.</li>
|
||||
<li><code>FpsCommandBus.SubmitCommand</code> dispatches commands.</li>
|
||||
<li>Networking code can submit the same payload from client input, server RPCs, prediction buffers, or replay.</li>
|
||||
</ul>
|
||||
<p>State flow:</p>
|
||||
<ul>
|
||||
<li><code>FpsStateReplicationController.CaptureSnapshot</code> builds a transport-neutral state packet.</li>
|
||||
<li><code>ApplyAuthoritativeSnapshot</code> applies authoritative position, rotation, velocity, camera, weapon, ADS, and parkour state.</li>
|
||||
<li><code>SnapshotCaptured</code> and <code>SnapshotApplied</code> are available for prediction/reconciliation layers.</li>
|
||||
</ul>
|
||||
<p>For multiplayer projects, keep <code>FPSModule</code> but disable or remove <code>FpsLocalInputCommandSource</code> on non-owning proxies.</p>
|
||||
<h2 id="16-troubleshooting" class="sec">16. Troubleshooting</h2>
|
||||
<p>Use <code>Tools > Character Controller > Validation Window</code> first.</p>
|
||||
<h3 id="character-does-not-move">Character Does Not Move</h3>
|
||||
<ul>
|
||||
<li>Confirm <code>PlayerController</code>, <code>Rigidbody</code>, <code>CapsuleCollider</code>, and <code>InputHandler</code> are on the same root.</li>
|
||||
<li>Confirm <code>InputHandler -> Movement Actions Asset</code> is assigned.</li>
|
||||
<li>Confirm <code>Movement Action Map Name</code> matches the action map, usually <code>Control</code>.</li>
|
||||
<li>Confirm <code>Move</code> exists and is a <code>Vector2</code>.</li>
|
||||
<li>Confirm Unity Input System is enabled.</li>
|
||||
<li>Confirm your code is not calling <code>SetMovementEnabled(false)</code>.</li>
|
||||
</ul>
|
||||
<h3 id="input-map-missing">Input Map Missing</h3>
|
||||
<ul>
|
||||
<li>Core movement expects a map named <code>Control</code> unless changed.</li>
|
||||
<li>Required core actions are <code>Move</code>, <code>Jump</code>, <code>Crouch</code>, <code>Prone</code>, <code>Dash</code>, <code>Walk</code>, and <code>Sprint</code>.</li>
|
||||
<li>Add-on action maps belong in <code>InputHandler -> Extension Action Assets</code>.</li>
|
||||
<li>The FPS add-on expects a map named <code>FPS</code>.</li>
|
||||
</ul>
|
||||
<h3 id="bad-layer-masks">Bad Layer Masks</h3>
|
||||
<ul>
|
||||
<li><code>GroundLayerMask</code> must include ordinary walkable ground.</li>
|
||||
<li><code>StairsLayerMask</code> must include stair/step geometry.</li>
|
||||
<li>Empty masks prevent ground detection.</li>
|
||||
<li>Do not put the player body layer in ground masks unless your scene intentionally requires it.</li>
|
||||
</ul>
|
||||
<h3 id="jitter-on-stairs">Jitter On Stairs</h3>
|
||||
<ul>
|
||||
<li>Use simple stable colliders. Avoid tiny overlapping stair colliders.</li>
|
||||
<li>Set <code>StepHeight</code> slightly above visible stair riser height.</li>
|
||||
<li>Increase <code>StepCheckDistance</code> if the controller reaches the riser too late.</li>
|
||||
<li>Increase <code>GroundSnapDistance</code> only enough to remove flicker.</li>
|
||||
<li>Keep <code>GroundStickForce</code> moderate.</li>
|
||||
<li>Test at 30, 60, and 120 FPS.</li>
|
||||
</ul>
|
||||
<h3 id="cannot-stand-from-crouch-or-prone">Cannot Stand From Crouch Or Prone</h3>
|
||||
<ul>
|
||||
<li>Check for a ceiling or collider above the capsule.</li>
|
||||
<li>Lower <code>CrouchCapsuleHeight</code> or <code>ProneCapsuleHeight</code> for low cover.</li>
|
||||
<li>Keep <code>CeilingCheckDistance</code> small but positive.</li>
|
||||
<li>Confirm child visual colliders are not blocking the body capsule.</li>
|
||||
</ul>
|
||||
<h3 id="camera-not-rotating">Camera Not Rotating</h3>
|
||||
<ul>
|
||||
<li>For third-person, confirm <code>CameraFollow</code> is on the active camera and has a target.</li>
|
||||
<li>For FPS, confirm <code>FpsCameraController</code> and <code>FpsLocalInputCommandSource</code> are present.</li>
|
||||
<li>Confirm <code>SetLookEnabled(false)</code> is not active.</li>
|
||||
<li>Confirm look input exists in the FPS input map.</li>
|
||||
<li>Confirm the active camera is tagged <code>MainCamera</code> when relying on automatic camera-relative movement.</li>
|
||||
</ul>
|
||||
<h3 id="fps-input-not-firing">FPS Input Not Firing</h3>
|
||||
<ul>
|
||||
<li>Add <code>FPSControls.inputactions</code> to <code>InputHandler -> Extension Action Assets</code>.</li>
|
||||
<li>Confirm the map is named <code>FPS</code>.</li>
|
||||
<li>Confirm required FPS actions exist.</li>
|
||||
<li>Confirm <code>FPSModule</code> is on the player.</li>
|
||||
<li>Confirm local player objects keep <code>FpsLocalInputCommandSource</code> enabled.</li>
|
||||
<li>For multiplayer proxies, disable local input only on non-owning instances.</li>
|
||||
</ul>
|
||||
<h3 id="slides-do-not-start">Slides Do Not Start</h3>
|
||||
<ul>
|
||||
<li>Slide starts from crouch intent while sprinting only when slide conditions are valid.</li>
|
||||
<li>Confirm the player is moving faster than <code>MinimumSlideInputSpeed</code>.</li>
|
||||
<li>Confirm <code>SlideCooldown</code> is not active.</li>
|
||||
<li>Confirm movement is enabled.</li>
|
||||
</ul>
|
||||
<h3 id="jump-buffer-or-coyote-time-does-not-work">Jump Buffer Or Coyote Time Does Not Work</h3>
|
||||
<ul>
|
||||
<li>Confirm <code>JumpBufferTime</code> and <code>CoyoteTime</code> are greater than zero.</li>
|
||||
<li>Confirm the <code>Jump</code> action fires <code>performed</code>.</li>
|
||||
<li>Confirm a parkour module is not intentionally consuming the buffered jump first.</li>
|
||||
</ul>
|
||||
<h3 id="moving-platforms-slip-or-jitter">Moving Platforms Slip Or Jitter</h3>
|
||||
<ul>
|
||||
<li>Add <code>MovingPlatform</code> to the platform.</li>
|
||||
<li>For Rigidbody platforms, assign the platform Rigidbody or let <code>MovingPlatform.Reset</code> find it.</li>
|
||||
<li>For scripted transform platforms, leave <code>preferRigidbodyVelocity</code> disabled or do not assign a Rigidbody.</li>
|
||||
<li>Move scripted platforms from <code>FixedUpdate</code> when possible.</li>
|
||||
</ul>
|
||||
<h2 id="17-migration-notes" class="sec">17. Migration Notes</h2>
|
||||
<p>Current package contains:</p>
|
||||
<ul>
|
||||
<li><code>Core</code></li>
|
||||
<li><code>FPSFirstPerson</code></li>
|
||||
</ul>
|
||||
<p>Core is standalone. FPS depends on Core.</p>
|
||||
<p>Buyer-visible migration points:</p>
|
||||
<ul>
|
||||
<li><code>SprintSpeed</code> is the target sprint speed, not a bonus added to <code>Speed</code>.</li>
|
||||
<li>Input inspector labels are <code>Movement Actions Asset</code>, <code>Movement Action Map Name</code>, and <code>Extension Action Assets</code>.</li>
|
||||
<li>Movement tuning can be assigned through <code>CharacterMotorSettings</code>.</li>
|
||||
<li>Animation integration should use <code>CharacterAnimatorBridge</code> and <code>CharacterAnimatorParameters</code>.</li>
|
||||
<li>Stable public APIs should be used for integrations instead of private fields.</li>
|
||||
<li>Add <code>MovingPlatform</code> to platforms the character should ride.</li>
|
||||
<li>Use <code>CharacterCinemachineAdapter</code> for Cinemachine rigs. Do not add a hard Cinemachine assembly reference to Core.</li>
|
||||
</ul>
|
||||
<h2 id="18-support-checklist" class="sec">18. Support Checklist</h2>
|
||||
<p>When reporting a problem, include:</p>
|
||||
<ul>
|
||||
<li>Unity version.</li>
|
||||
<li>Whether Input System is enabled.</li>
|
||||
<li>Scene or prefab used.</li>
|
||||
<li>Screenshots of <code>PlayerController</code>, <code>InputHandler</code>, and relevant FPS components.</li>
|
||||
<li>Ground/stair layer setup.</li>
|
||||
<li>Input action asset setup.</li>
|
||||
<li>Console errors or warnings.</li>
|
||||
<li>Steps to reproduce.</li>
|
||||
</ul>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c14a4855f90714482a27569bb30b59
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/Character Controller
|
||||
Manual (Printable).html
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c86a1fdee7c4254eb6c7232b5c9e7ab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 567 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a2c14df857d0464389f9e7825a650e2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/core-demo-scene.png
|
||||
uploadId: 997018
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 273 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35d8394e702bcaa459bae67663472603
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/fps-wizard.png
|
||||
uploadId: 997018
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39f519c183b99ee43a01be7479fd40cf
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/motor-settings.png
|
||||
uploadId: 997018
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 171 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffef4e2d73d1f5647a048bc21fbd63c6
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/player-inspector.png
|
||||
uploadId: 997018
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ea00b06746bbf5488c9ab83cd7c1ec6
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/setup-wizard.png
|
||||
uploadId: 997018
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
@@ -0,0 +1,150 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dfa0d490dd1f4145828f3c7e8ec14a7
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Documentation/images/validation-window.png
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1efc6b241be9d54780dcd404eeae4b9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
// Auto-opens on first import so buyers always have a clear entry point,
|
||||
// then hands off to the Setup Wizard. Editor-only, self-contained.
|
||||
[InitializeOnLoad]
|
||||
internal static class CharacterControllerStartup
|
||||
{
|
||||
private const string AutoShowKey = "MotionCore.GettingStarted.AutoShow";
|
||||
|
||||
static CharacterControllerStartup()
|
||||
{
|
||||
EditorApplication.delayCall += TryAutoShow;
|
||||
}
|
||||
|
||||
private static void TryAutoShow()
|
||||
{
|
||||
if (!EditorPrefs.GetBool(AutoShowKey, true))
|
||||
return;
|
||||
|
||||
// Show once per project (keyed by product GUID), not on every recompile.
|
||||
string shownKey = "MotionCore.GettingStarted.Shown." + PlayerSettings.productGUID;
|
||||
if (EditorPrefs.GetBool(shownKey, false))
|
||||
return;
|
||||
|
||||
EditorPrefs.SetBool(shownKey, true);
|
||||
CharacterControllerGettingStarted.Open();
|
||||
}
|
||||
|
||||
internal static bool AutoShow
|
||||
{
|
||||
get => EditorPrefs.GetBool(AutoShowKey, true);
|
||||
set => EditorPrefs.SetBool(AutoShowKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CharacterControllerGettingStarted : EditorWindow
|
||||
{
|
||||
private const string Root = "Assets/Character Controller";
|
||||
private const string CoreDemoScene = Root + "/Core/Scenes/DemoScene.unity";
|
||||
private const string FpsDemoScene = Root + "/FPSFirstPerson/Scenes/FPSDemoScene.unity";
|
||||
private const string PrintableManual = Root + "/Core/Documentation/Character Controller Manual (Printable).html";
|
||||
private const string Manual = Root + "/MANUAL.md";
|
||||
private const string DocumentationFolder = Root + "/Core/Documentation";
|
||||
|
||||
private Vector2 _scroll;
|
||||
private GUIStyle _h1;
|
||||
private GUIStyle _step;
|
||||
private GUIStyle _body;
|
||||
|
||||
[MenuItem("Tools/Character Controller/Getting Started", false, -100)]
|
||||
public static void Open()
|
||||
{
|
||||
CharacterControllerGettingStarted window = GetWindow<CharacterControllerGettingStarted>(true, "Character Controller");
|
||||
window.minSize = new Vector2(460f, 620f);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void BuildStyles()
|
||||
{
|
||||
if (_h1 != null)
|
||||
return;
|
||||
|
||||
_h1 = new GUIStyle(EditorStyles.boldLabel) { fontSize = 17 };
|
||||
_step = new GUIStyle(EditorStyles.boldLabel) { fontSize = 13 };
|
||||
_body = new GUIStyle(EditorStyles.label) { wordWrap = true };
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
BuildStyles();
|
||||
_scroll = EditorGUILayout.BeginScrollView(_scroll);
|
||||
|
||||
EditorGUILayout.Space(6f);
|
||||
EditorGUILayout.LabelField("Motion Core Character Controller", _h1);
|
||||
EditorGUILayout.LabelField("Welcome! Follow the three steps below to get a controller running in a couple of minutes.", _body);
|
||||
EditorGUILayout.Space(8f);
|
||||
|
||||
DrawEnvironmentCheck();
|
||||
DrawStepTryDemo();
|
||||
DrawStepBuildYourOwn();
|
||||
DrawDocs();
|
||||
DrawFooter();
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
// ---- Step 0: Environment health check -------------------------------
|
||||
|
||||
private void DrawEnvironmentCheck()
|
||||
{
|
||||
EditorGUILayout.LabelField("1. Check your project is ready", _step);
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
EditorGUILayout.HelpBox("Input System backend is active. Your project is ready.", MessageType.Info);
|
||||
#else
|
||||
EditorGUILayout.HelpBox(
|
||||
"This package needs the Input System backend. Set Edit > Project Settings > Player > " +
|
||||
"Active Input Handling to \"Input System Package\" or \"Both\", then let Unity restart. " +
|
||||
"Until then the controller will not receive input.",
|
||||
MessageType.Error);
|
||||
if (GUILayout.Button("Open Player Settings"))
|
||||
SettingsService.OpenProjectSettings("Project/Player");
|
||||
#endif
|
||||
|
||||
EditorGUILayout.Space(10f);
|
||||
}
|
||||
|
||||
// ---- Step 1: Try a ready-made demo ----------------------------------
|
||||
|
||||
private void DrawStepTryDemo()
|
||||
{
|
||||
EditorGUILayout.LabelField("2. Try a ready-made demo scene", _step);
|
||||
EditorGUILayout.LabelField("Open a demo and press Play. Move with WASD, jump with Space, press F1 to toggle the on-screen help.", _body);
|
||||
EditorGUILayout.Space(4f);
|
||||
|
||||
using (new EditorGUI.DisabledScope(!SceneExists(CoreDemoScene)))
|
||||
{
|
||||
if (GUILayout.Button("Open Core Demo Scene", GUILayout.Height(30f)))
|
||||
OpenScene(CoreDemoScene);
|
||||
}
|
||||
|
||||
bool hasFps = SceneExists(FpsDemoScene);
|
||||
using (new EditorGUI.DisabledScope(!hasFps))
|
||||
{
|
||||
if (GUILayout.Button(hasFps ? "Open FPS Demo Scene" : "Open FPS Demo Scene (add-on not imported)", GUILayout.Height(30f)))
|
||||
OpenScene(FpsDemoScene);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10f);
|
||||
}
|
||||
|
||||
// ---- Step 2: Build your own controller ------------------------------
|
||||
|
||||
private void DrawStepBuildYourOwn()
|
||||
{
|
||||
EditorGUILayout.LabelField("3. Add a controller to your own scene", _step);
|
||||
EditorGUILayout.LabelField("The Setup Wizard creates a fully wired player (components, input, camera, presets) in one click. Run Validate afterwards to catch setup mistakes.", _body);
|
||||
EditorGUILayout.Space(4f);
|
||||
|
||||
if (GUILayout.Button("Open Setup Wizard", GUILayout.Height(34f)))
|
||||
EditorApplication.ExecuteMenuItem("Tools/Character Controller/Setup Wizard");
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Validate a Player"))
|
||||
EditorApplication.ExecuteMenuItem("Tools/Character Controller/Validation Window");
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(10f);
|
||||
}
|
||||
|
||||
// ---- Docs -----------------------------------------------------------
|
||||
|
||||
private void DrawDocs()
|
||||
{
|
||||
EditorGUILayout.LabelField("Documentation", _step);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Open Printable Manual (PDF-ready)"))
|
||||
OpenExternal(PrintableManual, Manual);
|
||||
|
||||
if (GUILayout.Button("Open Manual (text)"))
|
||||
PingAsset(Manual);
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Show Documentation Folder"))
|
||||
PingAsset(DocumentationFolder);
|
||||
|
||||
EditorGUILayout.Space(10f);
|
||||
}
|
||||
|
||||
private void DrawFooter()
|
||||
{
|
||||
EditorGUILayout.Space(6f);
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
bool auto = EditorGUILayout.ToggleLeft("Show this window on project startup", CharacterControllerStartup.AutoShow);
|
||||
if (auto != CharacterControllerStartup.AutoShow)
|
||||
CharacterControllerStartup.AutoShow = auto;
|
||||
}
|
||||
EditorGUILayout.LabelField("You can reopen this any time from Tools > Character Controller > Getting Started.", EditorStyles.miniLabel);
|
||||
}
|
||||
|
||||
// ---- Helpers --------------------------------------------------------
|
||||
|
||||
private static bool SceneExists(string assetPath)
|
||||
{
|
||||
return !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(assetPath));
|
||||
}
|
||||
|
||||
private static void OpenScene(string assetPath)
|
||||
{
|
||||
if (!SceneExists(assetPath))
|
||||
{
|
||||
EditorUtility.DisplayDialog("Character Controller", "Demo scene not found:\n" + assetPath, "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
return;
|
||||
|
||||
EditorSceneManager.OpenScene(assetPath, OpenSceneMode.Single);
|
||||
}
|
||||
|
||||
// Opens an external file (e.g. the printable HTML) in the OS default app,
|
||||
// falling back to pinging a second asset if the first is missing.
|
||||
private static void OpenExternal(string primaryAssetPath, string fallbackAssetPath)
|
||||
{
|
||||
string full = ToAbsolute(primaryAssetPath);
|
||||
if (File.Exists(full))
|
||||
{
|
||||
Application.OpenURL(new Uri(full).AbsoluteUri);
|
||||
return;
|
||||
}
|
||||
|
||||
PingAsset(fallbackAssetPath);
|
||||
}
|
||||
|
||||
private static void PingAsset(string assetPath)
|
||||
{
|
||||
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath);
|
||||
if (obj == null)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Character Controller", "Not found:\n" + assetPath, "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUIUtility.PingObject(obj);
|
||||
Selection.activeObject = obj;
|
||||
}
|
||||
|
||||
private static string ToAbsolute(string assetPath)
|
||||
{
|
||||
// Application.dataPath ends with "/Assets"; asset paths start with "Assets/".
|
||||
string projectRoot = Directory.GetParent(Application.dataPath).FullName;
|
||||
return Path.GetFullPath(Path.Combine(projectRoot, assetPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c8870ff91414ce4e9d7ccab9745f9a7
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterControllerGettingStarted.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,454 @@
|
||||
using CharacterMovement;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
public sealed class CharacterControllerSetupWizard : EditorWindow
|
||||
{
|
||||
private const string CoreInputPath = "Assets/Character Controller/Core/Scripts/Input/Controls.inputactions";
|
||||
private const string ParkourLiteMotorSettingsPath = "Assets/Character Controller/Core/Data/ParkourLiteMotorSettings.asset";
|
||||
private const string TacticalMotorSettingsPath = "Assets/Character Controller/Core/Data/TacticalFPSMotorSettings.asset";
|
||||
private const string FpsInputPath = "Assets/Character Controller/FPSFirstPerson/Input/FPSControls.inputactions";
|
||||
private const string FpsCameraConfigPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoFpsCamera.asset";
|
||||
private const string FpsAdsSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoAdsSettings.asset";
|
||||
private const string FpsParkourSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoParkourSettings.asset";
|
||||
private const string FpsRecoilProfilePath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoRifleRecoil.asset";
|
||||
private const string FpsSwayProfilePath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoWeaponSway.asset";
|
||||
private const string FpsRifleDefinitionPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoRifle.asset";
|
||||
private const string FpsHitmarkerSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoHitmarkerSettings.asset";
|
||||
|
||||
private static readonly string[] FpsComponentTypeNames =
|
||||
{
|
||||
"CharacterMovement.FPS.FPSInputHandler",
|
||||
"CharacterMovement.FPS.FpsCommandBus",
|
||||
"CharacterMovement.FPS.FpsLocalInputCommandSource",
|
||||
"CharacterMovement.FPS.FpsStateReplicationController",
|
||||
"CharacterMovement.FPS.FpsCameraController",
|
||||
"CharacterMovement.FPS.FPSViewMotion",
|
||||
"CharacterMovement.FPS.AdsController",
|
||||
"CharacterMovement.FPS.WeaponSwayController",
|
||||
"CharacterMovement.FPS.RecoilController",
|
||||
"CharacterMovement.FPS.WeaponManager",
|
||||
"CharacterMovement.FPS.FpsInteractor",
|
||||
"CharacterMovement.FPS.FpsInventory",
|
||||
"CharacterMovement.FPS.InventoryWeaponLoadoutBinder",
|
||||
"CharacterMovement.FPS.SurfaceDetector",
|
||||
"CharacterMovement.FPS.FootstepController",
|
||||
"CharacterMovement.FPS.HitmarkerFeedbackController",
|
||||
"CharacterMovement.FPS.ProjectileImpactEffectSpawner",
|
||||
"CharacterMovement.FPS.FpsParkourController",
|
||||
"CharacterMovement.FPS.FPSModule"
|
||||
};
|
||||
|
||||
[SerializeField] private SetupMode setupMode = SetupMode.FPS;
|
||||
[SerializeField] private GameObject targetPlayer;
|
||||
[SerializeField] private bool createNewPlayer = true;
|
||||
[SerializeField] private bool createCameraRig = true;
|
||||
[SerializeField] private bool assignDemoFpsWeapon = true;
|
||||
[SerializeField] private LayerMask groundLayerMask = 1;
|
||||
[SerializeField] private LayerMask stairsLayerMask = 1;
|
||||
|
||||
private Vector2 _scroll;
|
||||
private string _lastResult;
|
||||
|
||||
private enum SetupMode
|
||||
{
|
||||
Core,
|
||||
FPS
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Character Controller/Setup Wizard", false, -20)]
|
||||
public static void Open()
|
||||
{
|
||||
CharacterControllerSetupWizard window = GetWindow<CharacterControllerSetupWizard>("CC Setup Wizard");
|
||||
window.minSize = new Vector2(440f, 500f);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!targetPlayer && Selection.activeGameObject)
|
||||
targetPlayer = Selection.activeGameObject.GetComponentInParent<PlayerController>()?.gameObject ?? Selection.activeGameObject;
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
_scroll = EditorGUILayout.BeginScrollView(_scroll);
|
||||
|
||||
EditorGUILayout.LabelField("Motion Core Setup Wizard", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox(
|
||||
"Use this wizard when you do not want to manually pick scripts from the package. It creates or configures a player with the expected components, input assets, presets, camera references, and FPS add-on wiring.",
|
||||
MessageType.Info);
|
||||
|
||||
DrawSetupOptions();
|
||||
DrawActions();
|
||||
DrawResult();
|
||||
|
||||
EditorGUILayout.Space(10f);
|
||||
EditorGUILayout.LabelField("What It Creates", EditorStyles.boldLabel);
|
||||
DrawModeDescription();
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void DrawSetupOptions()
|
||||
{
|
||||
EditorGUILayout.Space(8f);
|
||||
setupMode = (SetupMode)EditorGUILayout.EnumPopup("Controller Type", setupMode);
|
||||
if (setupMode == SetupMode.FPS && !CharacterControllerSetupWizardUtility.HasFpsAddOn())
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"The FPS add-on is not available in this project. Import FPSFirstPerson or switch Controller Type to Core.",
|
||||
MessageType.Warning);
|
||||
}
|
||||
|
||||
createNewPlayer = EditorGUILayout.Toggle("Create New Player", createNewPlayer);
|
||||
|
||||
using (new EditorGUI.DisabledScope(createNewPlayer))
|
||||
targetPlayer = (GameObject)EditorGUILayout.ObjectField("Target Player", targetPlayer, typeof(GameObject), true);
|
||||
|
||||
createCameraRig = EditorGUILayout.Toggle(setupMode == SetupMode.FPS ? "Create FPS Camera Rig" : "Create CameraFollow Rig", createCameraRig);
|
||||
if (setupMode == SetupMode.FPS)
|
||||
assignDemoFpsWeapon = EditorGUILayout.Toggle("Assign Demo Rifle", assignDemoFpsWeapon);
|
||||
|
||||
groundLayerMask = CharacterControllerSetupWizardUtility.LayerMaskField("Ground Layers", groundLayerMask);
|
||||
stairsLayerMask = CharacterControllerSetupWizardUtility.LayerMaskField("Stairs Layers", stairsLayerMask);
|
||||
}
|
||||
|
||||
private void DrawActions()
|
||||
{
|
||||
EditorGUILayout.Space(10f);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
using (new EditorGUI.DisabledScope(setupMode == SetupMode.FPS && !CharacterControllerSetupWizardUtility.HasFpsAddOn()))
|
||||
{
|
||||
if (GUILayout.Button(createNewPlayer ? "Create Controller" : "Configure Selected", GUILayout.Height(34f)))
|
||||
RunSetup();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Validate", GUILayout.Height(34f)))
|
||||
OpenValidatorForTarget();
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Build Core Demo"))
|
||||
EditorApplication.ExecuteMenuItem("Tools/Character Controller/Build Demo Scene");
|
||||
|
||||
using (new EditorGUI.DisabledScope(!CharacterControllerSetupWizardUtility.HasFpsAddOn()))
|
||||
{
|
||||
if (GUILayout.Button("Build FPS Demo"))
|
||||
EditorApplication.ExecuteMenuItem("Tools/Character Controller/Build FPS Demo Scene");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawResult()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_lastResult))
|
||||
return;
|
||||
|
||||
EditorGUILayout.Space(8f);
|
||||
EditorGUILayout.HelpBox(_lastResult, MessageType.Info);
|
||||
}
|
||||
|
||||
private void DrawModeDescription()
|
||||
{
|
||||
if (setupMode == SetupMode.Core)
|
||||
{
|
||||
EditorGUILayout.HelpBox(
|
||||
"Core setup adds Rigidbody, CapsuleCollider, InputHandler, PlayerController, the core input asset, a movement preset, walkable layer masks, and an optional third-person CameraFollow rig.",
|
||||
MessageType.None);
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
"FPS setup includes the Core setup plus FPS input, command bus, first-person camera, view motion, ADS, recoil, weapon sway, weapon manager, interaction, inventory, footsteps, hitmarker feedback, parkour, and FPSModule. Demo weapon data is optional.",
|
||||
MessageType.None);
|
||||
}
|
||||
|
||||
private void RunSetup()
|
||||
{
|
||||
if (setupMode == SetupMode.FPS && !CharacterControllerSetupWizardUtility.HasFpsAddOn())
|
||||
{
|
||||
EditorUtility.DisplayDialog("Setup Wizard", "The FPS add-on is not imported. Switch to Core setup or import FPSFirstPerson.", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject player = ResolvePlayer();
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
Undo.SetCurrentGroupName("Character Controller Setup Wizard");
|
||||
int undoGroup = Undo.GetCurrentGroup();
|
||||
|
||||
PlayerController controller = ConfigureCore(player);
|
||||
if (setupMode == SetupMode.FPS)
|
||||
ConfigureFps(player);
|
||||
|
||||
Selection.activeGameObject = player;
|
||||
EditorGUIUtility.PingObject(player);
|
||||
EditorSceneManager.MarkSceneDirty(player.scene);
|
||||
Undo.CollapseUndoOperations(undoGroup);
|
||||
|
||||
_lastResult = $"{setupMode} controller configured on '{player.name}'. Run Validate to review project-specific layer, input, and reference warnings.";
|
||||
Repaint();
|
||||
|
||||
if (controller)
|
||||
OpenValidatorForTarget();
|
||||
}
|
||||
|
||||
private GameObject ResolvePlayer()
|
||||
{
|
||||
if (createNewPlayer)
|
||||
{
|
||||
GameObject player = new GameObject(setupMode == SetupMode.FPS ? "FPS Player" : "Motion Core Player");
|
||||
Undo.RegisterCreatedObjectUndo(player, "Create Character Controller Player");
|
||||
player.tag = CharacterControllerSetupWizardUtility.EnsureTag("Player") ? "Player" : player.tag;
|
||||
player.transform.position = Vector3.zero;
|
||||
targetPlayer = player;
|
||||
return player;
|
||||
}
|
||||
|
||||
if (targetPlayer)
|
||||
return targetPlayer;
|
||||
|
||||
EditorUtility.DisplayDialog("Setup Wizard", "Assign a Target Player or enable Create New Player.", "OK");
|
||||
return null;
|
||||
}
|
||||
|
||||
private PlayerController ConfigureCore(GameObject player)
|
||||
{
|
||||
Rigidbody body = GetOrAddComponent<Rigidbody>(player);
|
||||
CapsuleCollider capsule = GetOrAddComponent<CapsuleCollider>(player);
|
||||
InputHandler inputHandler = GetOrAddComponent<InputHandler>(player);
|
||||
PlayerController controller = GetOrAddComponent<PlayerController>(player);
|
||||
|
||||
ConfigureRigidbody(body);
|
||||
ConfigureCapsule(capsule);
|
||||
ConfigureInputHandler(inputHandler, setupMode == SetupMode.FPS);
|
||||
ConfigurePlayerController(controller, body, inputHandler, capsule);
|
||||
|
||||
if (createCameraRig && setupMode == SetupMode.Core)
|
||||
ConfigureThirdPersonCamera(player.transform);
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void ConfigureRigidbody(Rigidbody body)
|
||||
{
|
||||
Undo.RecordObject(body, "Configure Character Rigidbody");
|
||||
body.isKinematic = false;
|
||||
body.useGravity = true;
|
||||
body.freezeRotation = true;
|
||||
body.interpolation = RigidbodyInterpolation.Interpolate;
|
||||
body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||
EditorUtility.SetDirty(body);
|
||||
}
|
||||
|
||||
private void ConfigureCapsule(CapsuleCollider capsule)
|
||||
{
|
||||
Undo.RecordObject(capsule, "Configure Character Capsule");
|
||||
capsule.radius = 0.32f;
|
||||
capsule.height = 1.8f;
|
||||
capsule.center = new Vector3(0f, 0.9f, 0f);
|
||||
capsule.direction = 1;
|
||||
EditorUtility.SetDirty(capsule);
|
||||
}
|
||||
|
||||
private void ConfigureInputHandler(InputHandler inputHandler, bool includeFpsInput)
|
||||
{
|
||||
SerializedObject serializedInput = new SerializedObject(inputHandler);
|
||||
serializedInput.FindProperty("movementActionMapName").stringValue = "Control";
|
||||
serializedInput.FindProperty("movementActionsAsset").objectReferenceValue = AssetDatabase.LoadAssetAtPath<InputActionAsset>(CoreInputPath);
|
||||
|
||||
SerializedProperty extensionAssets = serializedInput.FindProperty("extensionActionAssets");
|
||||
if (includeFpsInput)
|
||||
{
|
||||
InputActionAsset fpsInput = AssetDatabase.LoadAssetAtPath<InputActionAsset>(FpsInputPath);
|
||||
extensionAssets.arraySize = fpsInput ? 1 : 0;
|
||||
if (fpsInput)
|
||||
extensionAssets.GetArrayElementAtIndex(0).objectReferenceValue = fpsInput;
|
||||
}
|
||||
else
|
||||
{
|
||||
extensionAssets.arraySize = 0;
|
||||
}
|
||||
|
||||
serializedInput.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(inputHandler);
|
||||
}
|
||||
|
||||
private void ConfigurePlayerController(PlayerController controller, Rigidbody body, InputHandler inputHandler, CapsuleCollider capsule)
|
||||
{
|
||||
SerializedObject serializedController = new SerializedObject(controller);
|
||||
serializedController.FindProperty("<RigidBody>k__BackingField").objectReferenceValue = body;
|
||||
serializedController.FindProperty("<InputHandler>k__BackingField").objectReferenceValue = inputHandler;
|
||||
serializedController.FindProperty("<CapsuleCollider>k__BackingField").objectReferenceValue = capsule;
|
||||
serializedController.FindProperty("<MotorSettings>k__BackingField").objectReferenceValue =
|
||||
AssetDatabase.LoadAssetAtPath<CharacterMotorSettings>(setupMode == SetupMode.FPS ? TacticalMotorSettingsPath : ParkourLiteMotorSettingsPath);
|
||||
serializedController.FindProperty("<GroundLayerMask>k__BackingField").intValue = groundLayerMask.value != 0 ? groundLayerMask.value : LayerMask.GetMask("Default");
|
||||
serializedController.FindProperty("<StairsLayerMask>k__BackingField").intValue = stairsLayerMask.value != 0 ? stairsLayerMask.value : LayerMask.GetMask("Default");
|
||||
serializedController.FindProperty("<AlignToSlopeNormal>k__BackingField").boolValue = setupMode != SetupMode.FPS;
|
||||
serializedController.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(controller);
|
||||
}
|
||||
|
||||
private void ConfigureThirdPersonCamera(Transform player)
|
||||
{
|
||||
Camera camera = Camera.main;
|
||||
if (!camera)
|
||||
{
|
||||
GameObject cameraObject = new GameObject("Character Camera");
|
||||
Undo.RegisterCreatedObjectUndo(cameraObject, "Create Character Camera");
|
||||
cameraObject.tag = "MainCamera";
|
||||
cameraObject.transform.position = player.position + new Vector3(0f, 2.3f, -5f);
|
||||
cameraObject.transform.rotation = Quaternion.Euler(18f, 0f, 0f);
|
||||
camera = Undo.AddComponent<Camera>(cameraObject);
|
||||
Undo.AddComponent<AudioListener>(cameraObject);
|
||||
}
|
||||
|
||||
CameraFollow follow = camera.GetComponent<CameraFollow>() ?? Undo.AddComponent<CameraFollow>(camera.gameObject);
|
||||
SerializedObject serializedFollow = new SerializedObject(follow);
|
||||
serializedFollow.FindProperty("target").objectReferenceValue = player;
|
||||
serializedFollow.FindProperty("autoFindTargetInScene").boolValue = false;
|
||||
serializedFollow.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(follow);
|
||||
}
|
||||
|
||||
private void ConfigureFps(GameObject player)
|
||||
{
|
||||
for (int i = 0; i < FpsComponentTypeNames.Length; i++)
|
||||
CharacterControllerSetupWizardUtility.EnsureComponentByTypeName(player, FpsComponentTypeNames[i]);
|
||||
|
||||
Transform cameraRoot = createCameraRig ? EnsureChild(player.transform, "FPS Camera Root", new Vector3(0f, 1.55f, 0f)) : player.transform.Find("FPS Camera Root");
|
||||
Camera camera = null;
|
||||
if (createCameraRig && cameraRoot)
|
||||
camera = EnsureFpsCamera(cameraRoot);
|
||||
|
||||
Transform weaponRoot = cameraRoot ? EnsureChild(cameraRoot, "FPS Weapon Root", new Vector3(0.2f, -0.22f, 0.55f)) : null;
|
||||
|
||||
AssignFpsObjectReference(player, "CharacterMovement.FPS.FpsCameraController", "cameraRoot", cameraRoot);
|
||||
AssignFpsObjectReference(player, "CharacterMovement.FPS.FpsCameraController", "playerCamera", camera);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.FpsCameraController", "configuration", FpsCameraConfigPath);
|
||||
AssignFpsObjectReference(player, "CharacterMovement.FPS.FPSViewMotion", "weaponRoot", weaponRoot);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.AdsController", "settings", FpsAdsSettingsPath);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.WeaponSwayController", "profile", FpsSwayProfilePath);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.RecoilController", "fallbackProfile", FpsRecoilProfilePath);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.FpsParkourController", "settings", FpsParkourSettingsPath);
|
||||
AssignFpsAssetReference(player, "CharacterMovement.FPS.HitmarkerFeedbackController", "settings", FpsHitmarkerSettingsPath);
|
||||
AssignFpsObjectReference(player, "CharacterMovement.FPS.WeaponManager", "weaponRoot", weaponRoot);
|
||||
|
||||
if (assignDemoFpsWeapon)
|
||||
AssignFpsStartingWeapon(player);
|
||||
}
|
||||
|
||||
private Camera EnsureFpsCamera(Transform cameraRoot)
|
||||
{
|
||||
Transform cameraTransform = cameraRoot.Find("FPS Camera");
|
||||
GameObject cameraObject = cameraTransform ? cameraTransform.gameObject : new GameObject("FPS Camera");
|
||||
if (!cameraTransform)
|
||||
{
|
||||
Undo.RegisterCreatedObjectUndo(cameraObject, "Create FPS Camera");
|
||||
cameraObject.transform.SetParent(cameraRoot);
|
||||
cameraObject.transform.localPosition = Vector3.zero;
|
||||
cameraObject.transform.localRotation = Quaternion.identity;
|
||||
}
|
||||
|
||||
cameraObject.tag = CharacterControllerSetupWizardUtility.EnsureTag("MainCamera") ? "MainCamera" : cameraObject.tag;
|
||||
Camera camera = cameraObject.GetComponent<Camera>() ?? Undo.AddComponent<Camera>(cameraObject);
|
||||
camera.fieldOfView = 72f;
|
||||
camera.nearClipPlane = 0.03f;
|
||||
|
||||
if (!cameraObject.GetComponent<AudioListener>())
|
||||
Undo.AddComponent<AudioListener>(cameraObject);
|
||||
|
||||
return camera;
|
||||
}
|
||||
|
||||
private void AssignFpsStartingWeapon(GameObject player)
|
||||
{
|
||||
Component manager = CharacterControllerSetupWizardUtility.FindComponentByTypeName(player, "CharacterMovement.FPS.WeaponManager");
|
||||
if (!manager)
|
||||
return;
|
||||
|
||||
UnityEngine.Object rifle = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(FpsRifleDefinitionPath);
|
||||
if (!rifle)
|
||||
return;
|
||||
|
||||
SerializedObject serializedManager = new SerializedObject(manager);
|
||||
SerializedProperty startingWeapons = serializedManager.FindProperty("startingWeapons");
|
||||
if (startingWeapons == null || !startingWeapons.isArray)
|
||||
return;
|
||||
|
||||
startingWeapons.arraySize = 1;
|
||||
startingWeapons.GetArrayElementAtIndex(0).objectReferenceValue = rifle;
|
||||
serializedManager.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(manager);
|
||||
}
|
||||
|
||||
private void AssignFpsObjectReference(GameObject player, string typeName, string propertyName, UnityEngine.Object value)
|
||||
{
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
Component component = CharacterControllerSetupWizardUtility.FindComponentByTypeName(player, typeName);
|
||||
if (!component)
|
||||
return;
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(component);
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property == null)
|
||||
return;
|
||||
|
||||
property.objectReferenceValue = value;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(component);
|
||||
}
|
||||
|
||||
private void AssignFpsAssetReference(GameObject player, string typeName, string propertyName, string assetPath)
|
||||
{
|
||||
UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath);
|
||||
AssignFpsObjectReference(player, typeName, propertyName, asset);
|
||||
}
|
||||
|
||||
private Transform EnsureChild(Transform parent, string childName, Vector3 localPosition)
|
||||
{
|
||||
Transform child = parent.Find(childName);
|
||||
if (!child)
|
||||
{
|
||||
GameObject childObject = new GameObject(childName);
|
||||
Undo.RegisterCreatedObjectUndo(childObject, "Create " + childName);
|
||||
child = childObject.transform;
|
||||
child.SetParent(parent);
|
||||
}
|
||||
|
||||
child.localPosition = localPosition;
|
||||
child.localRotation = Quaternion.identity;
|
||||
child.localScale = Vector3.one;
|
||||
return child;
|
||||
}
|
||||
|
||||
private T GetOrAddComponent<T>(GameObject gameObject) where T : Component
|
||||
{
|
||||
T component = gameObject.GetComponent<T>();
|
||||
return component ? component : Undo.AddComponent<T>(gameObject);
|
||||
}
|
||||
|
||||
private void OpenValidatorForTarget()
|
||||
{
|
||||
if (targetPlayer)
|
||||
Selection.activeGameObject = targetPlayer;
|
||||
|
||||
PlayerController controller = targetPlayer ? targetPlayer.GetComponentInParent<PlayerController>() : null;
|
||||
if (controller)
|
||||
CharacterControllerValidationWindow.OpenFor(controller);
|
||||
else
|
||||
CharacterControllerValidationWindow.Open();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a19fa3bd51d41a3a8246d0c0df24f19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterControllerSetupWizard.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
internal static class CharacterControllerSetupWizardUtility
|
||||
{
|
||||
public static bool HasFpsAddOn()
|
||||
{
|
||||
return AssetDatabase.IsValidFolder("Assets/Character Controller/FPSFirstPerson")
|
||||
&& FindType("CharacterMovement.FPS.FPSModule") != null;
|
||||
}
|
||||
|
||||
public static Component EnsureComponentByTypeName(GameObject gameObject, string typeName)
|
||||
{
|
||||
Type type = FindType(typeName);
|
||||
if (type == null || !typeof(Component).IsAssignableFrom(type))
|
||||
{
|
||||
Debug.LogWarning($"[Motion Core Setup Wizard] Could not find component type '{typeName}'. Is the FPS add-on imported?");
|
||||
return null;
|
||||
}
|
||||
|
||||
Component existing = gameObject.GetComponent(type);
|
||||
return existing ? existing : Undo.AddComponent(gameObject, type);
|
||||
}
|
||||
|
||||
public static Component FindComponentByTypeName(GameObject gameObject, string typeName)
|
||||
{
|
||||
Type type = FindType(typeName);
|
||||
return type != null ? gameObject.GetComponent(type) : null;
|
||||
}
|
||||
|
||||
public static bool EnsureTag(string tag)
|
||||
{
|
||||
try
|
||||
{
|
||||
GameObject.FindGameObjectsWithTag(tag);
|
||||
return true;
|
||||
}
|
||||
catch (UnityException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static LayerMask LayerMaskField(string label, LayerMask selected)
|
||||
{
|
||||
string[] layerNames = new string[32];
|
||||
for (int i = 0; i < layerNames.Length; i++)
|
||||
{
|
||||
string layerName = LayerMask.LayerToName(i);
|
||||
layerNames[i] = string.IsNullOrEmpty(layerName) ? $"Layer {i}" : layerName;
|
||||
}
|
||||
|
||||
selected.value = EditorGUILayout.MaskField(label, selected.value, layerNames);
|
||||
return selected;
|
||||
}
|
||||
|
||||
private static Type FindType(string typeName)
|
||||
{
|
||||
Type type = Type.GetType(typeName + ", CharacterMovement.FPS");
|
||||
if (type != null)
|
||||
return type;
|
||||
|
||||
type = Type.GetType(typeName + ", CharacterMovement.Core");
|
||||
if (type != null)
|
||||
return type;
|
||||
|
||||
foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
type = assembly.GetType(typeName);
|
||||
if (type != null)
|
||||
return type;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dc95b4e0a5345cb8fc4c20d7db6859d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterControllerSetupWizardUtility.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,394 @@
|
||||
using System;
|
||||
using CharacterMovement;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
public sealed partial class CharacterControllerValidationWindow
|
||||
{
|
||||
private const string FpsInputPath = "Assets/Character Controller/FPSFirstPerson/Input/FPSControls.inputactions";
|
||||
private const string FpsCameraConfigPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoFpsCamera.asset";
|
||||
private const string FpsAdsSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoAdsSettings.asset";
|
||||
private const string FpsParkourSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoParkourSettings.asset";
|
||||
private const string FpsRecoilProfilePath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoRifleRecoil.asset";
|
||||
private const string FpsSwayProfilePath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoWeaponSway.asset";
|
||||
private const string FpsRifleDefinitionPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoRifle.asset";
|
||||
private const string FpsHitmarkerSettingsPath = "Assets/Character Controller/FPSFirstPerson/Examples/Data/DemoHitmarkerSettings.asset";
|
||||
private const string FpsAnimationsFolder = "Assets/Character Controller/FPSFirstPerson/Examples/Animations";
|
||||
private const string FpsAnimatorControllerPath = FpsAnimationsFolder + "/DemoLocomotion.controller";
|
||||
|
||||
private static readonly string[] RequiredFpsAnimationPaths =
|
||||
{
|
||||
FpsAnimatorControllerPath,
|
||||
FpsAnimationsFolder + "/DemoBody_Idle.anim",
|
||||
FpsAnimationsFolder + "/DemoBody_Crouch.anim",
|
||||
FpsAnimationsFolder + "/DemoBody_Prone.anim",
|
||||
FpsAnimationsFolder + "/DemoBody_GroundSlide.anim"
|
||||
};
|
||||
|
||||
private static readonly string[] RequiredFpsActions =
|
||||
{
|
||||
"Look",
|
||||
"Fire",
|
||||
"Aim",
|
||||
"Reload",
|
||||
"Melee",
|
||||
"Use",
|
||||
"Weapon1",
|
||||
"Weapon2",
|
||||
"Weapon3",
|
||||
"Weapon4"
|
||||
};
|
||||
|
||||
private void ValidateFpsInput()
|
||||
{
|
||||
InputHandler inputHandler = targetController.GetComponent<InputHandler>();
|
||||
if (!inputHandler || !HasFpsAddOnComponents(targetController.gameObject))
|
||||
return;
|
||||
|
||||
SerializedObject input = new SerializedObject(inputHandler);
|
||||
SerializedProperty extensionAssets = input.FindProperty("extensionActionAssets");
|
||||
InputActionAsset fpsAsset = FindActionAssetWithMap(extensionAssets, "FPS");
|
||||
if (fpsAsset)
|
||||
{
|
||||
ValidateActionMap(fpsAsset, "FPS", RequiredFpsActions, "FPS input");
|
||||
return;
|
||||
}
|
||||
|
||||
AddFix(
|
||||
"FPS extension input asset is missing",
|
||||
"The FPS add-on is present, but InputHandler does not reference an input asset with the FPS action map.",
|
||||
() => AppendExtensionInputAsset(inputHandler, AssetDatabase.LoadAssetAtPath<InputActionAsset>(FpsInputPath)));
|
||||
}
|
||||
|
||||
private void ValidateFpsDemoAssets()
|
||||
{
|
||||
if (!HasFpsAddOnComponents(targetController.gameObject) && !AssetDatabase.IsValidFolder("Assets/Character Controller/FPSFirstPerson"))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < RequiredFpsAnimationPaths.Length; i++)
|
||||
{
|
||||
if (!AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(RequiredFpsAnimationPaths[i]))
|
||||
{
|
||||
AddFix(
|
||||
"FPS demo animation assets are missing",
|
||||
"The FPS demo expects generated locomotion sample clips and an animator controller. Generate them before shipping or before opening the FPS demo scene.",
|
||||
CreateFpsDemoAnimationAssets);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateFpsCamera()
|
||||
{
|
||||
Component cameraController = FindComponentByTypeName(targetController.gameObject, "FpsCameraController");
|
||||
if (!cameraController)
|
||||
return;
|
||||
|
||||
SerializedObject camera = new SerializedObject(cameraController);
|
||||
SerializedProperty rootProperty = camera.FindProperty("cameraRoot");
|
||||
SerializedProperty configProperty = camera.FindProperty("configuration");
|
||||
|
||||
if (configProperty != null && !configProperty.objectReferenceValue)
|
||||
{
|
||||
AddFix(
|
||||
"FPS camera configuration is missing",
|
||||
"FpsCameraController will create a runtime fallback config. Assign a camera config asset so the camera starts at the intended eye height.",
|
||||
() => AssignSerializedObjectReference(cameraController, "configuration", AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(FpsCameraConfigPath)));
|
||||
}
|
||||
|
||||
Transform cameraRoot = rootProperty?.objectReferenceValue as Transform;
|
||||
if (cameraRoot && cameraRoot.localPosition.y < 1.2f)
|
||||
{
|
||||
AddFix(
|
||||
"FPS camera root is too low",
|
||||
"The FPS camera root is below eye height and will feel like the camera starts near the player's feet.",
|
||||
() =>
|
||||
{
|
||||
Undo.RecordObject(cameraRoot, "Fix FPS Camera Height");
|
||||
Vector3 position = cameraRoot.localPosition;
|
||||
position.y = 1.55f;
|
||||
if (Mathf.Abs(position.z) < 0.001f)
|
||||
position.z = 0.02f;
|
||||
cameraRoot.localPosition = position;
|
||||
EditorUtility.SetDirty(cameraRoot);
|
||||
MarkSceneDirty();
|
||||
});
|
||||
}
|
||||
|
||||
UnityEngine.Object config = configProperty?.objectReferenceValue;
|
||||
if (config)
|
||||
ValidateFpsCameraConfigHeight(config);
|
||||
}
|
||||
|
||||
private void ValidateFpsCameraConfigHeight(UnityEngine.Object config)
|
||||
{
|
||||
SerializedObject serializedConfig = new SerializedObject(config);
|
||||
SerializedProperty cameraLocalPosition = serializedConfig.FindProperty("cameraLocalPosition");
|
||||
if (cameraLocalPosition == null || cameraLocalPosition.vector3Value.y >= 1.2f)
|
||||
return;
|
||||
|
||||
AddFix(
|
||||
"FPS camera config eye height is too low",
|
||||
"FpsCameraConfig.CameraLocalPosition is below a normal standing eye height for the included controller capsule.",
|
||||
() =>
|
||||
{
|
||||
serializedConfig.Update();
|
||||
SerializedProperty freshPosition = serializedConfig.FindProperty("cameraLocalPosition");
|
||||
Vector3 position = freshPosition.vector3Value;
|
||||
position.y = 1.55f;
|
||||
if (Mathf.Abs(position.z) < 0.001f)
|
||||
position.z = 0.02f;
|
||||
freshPosition.vector3Value = position;
|
||||
serializedConfig.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(config);
|
||||
});
|
||||
}
|
||||
|
||||
private void ValidateFpsDemoReferences()
|
||||
{
|
||||
if (!HasFpsAddOnComponents(targetController.gameObject))
|
||||
return;
|
||||
|
||||
ValidateComponentObjectReference(
|
||||
"AdsController",
|
||||
"settings",
|
||||
FpsAdsSettingsPath,
|
||||
"FPS ADS settings are missing",
|
||||
"AdsController will use runtime fallback values. Assign an ADS settings asset for predictable demo and project behavior.");
|
||||
|
||||
ValidateComponentObjectReference(
|
||||
"FpsParkourController",
|
||||
"settings",
|
||||
FpsParkourSettingsPath,
|
||||
"FPS parkour settings are missing",
|
||||
"FpsParkourController will use runtime fallback values. Assign parkour settings so wall-run, mantle, vault, and ledge tuning are explicit.");
|
||||
|
||||
ValidateComponentObjectReference(
|
||||
"RecoilController",
|
||||
"fallbackProfile",
|
||||
FpsRecoilProfilePath,
|
||||
"FPS recoil profile is missing",
|
||||
"RecoilController needs a fallback profile for weapons that do not override recoil.");
|
||||
|
||||
ValidateComponentObjectReference(
|
||||
"WeaponSwayController",
|
||||
"profile",
|
||||
FpsSwayProfilePath,
|
||||
"FPS weapon sway profile is missing",
|
||||
"WeaponSwayController will use runtime fallback values. Assign a sway profile for predictable weapon presentation.");
|
||||
|
||||
ValidateComponentObjectReference(
|
||||
"HitmarkerFeedbackController",
|
||||
"settings",
|
||||
FpsHitmarkerSettingsPath,
|
||||
"FPS hitmarker settings are missing",
|
||||
"HitmarkerFeedbackController will dispatch events, but visual/audio receivers need a settings asset for predictable feedback timing and colors.");
|
||||
|
||||
ValidateWeaponManagerLoadout();
|
||||
}
|
||||
|
||||
private void ValidateFpsParkourSettings()
|
||||
{
|
||||
Component parkourController = FindComponentByTypeName(targetController.gameObject, "FpsParkourController");
|
||||
if (!parkourController)
|
||||
return;
|
||||
|
||||
SerializedObject serializedController = new SerializedObject(parkourController);
|
||||
SerializedProperty settingsProperty = serializedController.FindProperty("settings");
|
||||
UnityEngine.Object settings = settingsProperty?.objectReferenceValue;
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
SerializedObject serializedSettings = new SerializedObject(settings);
|
||||
|
||||
SerializedProperty parkourLayers = serializedSettings.FindProperty("parkourLayers");
|
||||
if (parkourLayers != null && parkourLayers.intValue == 0)
|
||||
{
|
||||
AddFix(
|
||||
"FPS parkour layer mask is empty",
|
||||
"FpsParkourSettings.ParkourLayers is empty, so mantle, vault, ledge, and wall-run detection cannot find world geometry.",
|
||||
() =>
|
||||
{
|
||||
SerializedObject freshSettings = new SerializedObject(settings);
|
||||
SerializedProperty freshMask = freshSettings.FindProperty("parkourLayers");
|
||||
if (freshMask != null)
|
||||
{
|
||||
int fallbackMask = targetController.GroundLayerMask.value != 0 ? targetController.GroundLayerMask.value : LayerMask.GetMask("Default");
|
||||
freshMask.intValue = fallbackMask;
|
||||
freshSettings.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SerializedProperty controlledDownwardSpeed = serializedSettings.FindProperty("wallRunControlledDownwardSpeed");
|
||||
SerializedProperty maximumDownwardSpeed = serializedSettings.FindProperty("maximumWallRunDownwardSpeed");
|
||||
if (controlledDownwardSpeed != null
|
||||
&& maximumDownwardSpeed != null
|
||||
&& maximumDownwardSpeed.floatValue < controlledDownwardSpeed.floatValue)
|
||||
{
|
||||
AddFix(
|
||||
"FPS wall-run downward speed limits conflict",
|
||||
"MaximumWallRunDownwardSpeed must be greater than or equal to WallRunControlledDownwardSpeed, otherwise valid wall-runs can fail or end inconsistently.",
|
||||
() => SetFloatProperty(settings, "maximumWallRunDownwardSpeed", Mathf.Max(0f, GetFloatProperty(settings, "wallRunControlledDownwardSpeed"))));
|
||||
}
|
||||
|
||||
SerializedProperty startHeight = serializedSettings.FindProperty("minimumWallRunStartHeight");
|
||||
SerializedProperty exitDistance = serializedSettings.FindProperty("wallRunGroundExitDistance");
|
||||
if (startHeight != null
|
||||
&& exitDistance != null
|
||||
&& startHeight.floatValue < exitDistance.floatValue + 0.05f)
|
||||
{
|
||||
AddFix(
|
||||
"FPS wall-run ground clearance values conflict",
|
||||
"MinimumWallRunStartHeight should stay above WallRunGroundExitDistance so ground-level wall contact cannot become wall-walking.",
|
||||
() => SetFloatProperty(settings, "minimumWallRunStartHeight", GetFloatProperty(settings, "wallRunGroundExitDistance") + 0.05f));
|
||||
}
|
||||
|
||||
SerializedProperty minimumWallNormalY = serializedSettings.FindProperty("minimumWallNormalY");
|
||||
SerializedProperty maximumWallNormalY = serializedSettings.FindProperty("maximumWallNormalY");
|
||||
if (minimumWallNormalY != null
|
||||
&& maximumWallNormalY != null
|
||||
&& maximumWallNormalY.floatValue < minimumWallNormalY.floatValue)
|
||||
{
|
||||
AddFix(
|
||||
"FPS wall-run normal range is invalid",
|
||||
"MaximumWallNormalY must be greater than or equal to MinimumWallNormalY, otherwise no wall can satisfy the configured normal range.",
|
||||
() => SetFloatProperty(settings, "maximumWallNormalY", GetFloatProperty(settings, "minimumWallNormalY")));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateComponentObjectReference(string componentTypeName, string propertyName, string assetPath, string title, string description)
|
||||
{
|
||||
Component component = FindComponentByTypeName(targetController.gameObject, componentTypeName);
|
||||
if (!component)
|
||||
return;
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(component);
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property == null || property.objectReferenceValue)
|
||||
return;
|
||||
|
||||
AddFix(title, description, () => AssignSerializedObjectReference(component, propertyName, AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath)));
|
||||
}
|
||||
|
||||
private void ValidateWeaponManagerLoadout()
|
||||
{
|
||||
Component weaponManager = FindComponentByTypeName(targetController.gameObject, "WeaponManager");
|
||||
if (!weaponManager)
|
||||
return;
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(weaponManager);
|
||||
SerializedProperty startingWeapons = serializedObject.FindProperty("startingWeapons");
|
||||
bool missingFirstWeapon = startingWeapons == null
|
||||
|| !startingWeapons.isArray
|
||||
|| startingWeapons.arraySize == 0
|
||||
|| !startingWeapons.GetArrayElementAtIndex(0).objectReferenceValue;
|
||||
|
||||
if (!missingFirstWeapon)
|
||||
return;
|
||||
|
||||
AddFix(
|
||||
"FPS starting weapon is missing",
|
||||
"WeaponManager has no starting weapon, so the FPS demo starts unarmed.",
|
||||
() => AssignFirstArrayObjectReference(weaponManager, "startingWeapons", AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(FpsRifleDefinitionPath)));
|
||||
}
|
||||
|
||||
private void AppendExtensionInputAsset(InputHandler inputHandler, InputActionAsset asset)
|
||||
{
|
||||
if (!asset)
|
||||
{
|
||||
Debug.LogWarning("[MotionCore Validator] FPS input asset was not found at " + FpsInputPath);
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedObject input = new SerializedObject(inputHandler);
|
||||
input.Update();
|
||||
SerializedProperty array = input.FindProperty("extensionActionAssets");
|
||||
if (array == null || !array.isArray)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < array.arraySize; i++)
|
||||
{
|
||||
if (array.GetArrayElementAtIndex(i).objectReferenceValue == asset)
|
||||
return;
|
||||
}
|
||||
|
||||
array.InsertArrayElementAtIndex(array.arraySize);
|
||||
array.GetArrayElementAtIndex(array.arraySize - 1).objectReferenceValue = asset;
|
||||
input.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(inputHandler);
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private void AssignFirstArrayObjectReference(UnityEngine.Object target, string propertyName, UnityEngine.Object value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
Debug.LogWarning("[MotionCore Validator] Asset was not found for array property '" + propertyName + "'.");
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(target);
|
||||
serializedObject.Update();
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property != null && property.isArray)
|
||||
{
|
||||
if (property.arraySize == 0)
|
||||
property.arraySize = 1;
|
||||
property.GetArrayElementAtIndex(0).objectReferenceValue = value;
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(target);
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private static float GetFloatProperty(UnityEngine.Object target, string propertyName)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(target);
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
return property != null ? property.floatValue : 0f;
|
||||
}
|
||||
|
||||
private static void SetFloatProperty(UnityEngine.Object target, string propertyName, float value)
|
||||
{
|
||||
SerializedObject serializedObject = new SerializedObject(target);
|
||||
serializedObject.Update();
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property != null)
|
||||
property.floatValue = value;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
|
||||
private static bool HasFpsAddOnComponents(GameObject gameObject)
|
||||
{
|
||||
Component[] components = gameObject.GetComponentsInChildren<Component>(true);
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (!component)
|
||||
continue;
|
||||
|
||||
Type componentType = component.GetType();
|
||||
string namespaceName = componentType.Namespace ?? string.Empty;
|
||||
if (namespaceName.StartsWith("CharacterMovement.FPS", StringComparison.Ordinal))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CreateFpsDemoAnimationAssets()
|
||||
{
|
||||
bool executed = EditorApplication.ExecuteMenuItem("Tools/Character Controller/Create FPS Demo Animation Assets");
|
||||
if (!executed)
|
||||
Debug.LogWarning("[MotionCore Validator] FPS demo animation generator menu item was not found.");
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b431f80d0754d179e0529d966067c97
|
||||
timeCreated: 1781733450
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterControllerValidationWindow.Fps.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,534 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CharacterMovement;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
public sealed partial class CharacterControllerValidationWindow : EditorWindow
|
||||
{
|
||||
private const string CoreInputPath = "Assets/Character Controller/Core/Scripts/Input/Controls.inputactions";
|
||||
private const string AnimatorParametersPath = "Assets/Character Controller/Core/Data/DefaultCharacterAnimatorParameters.asset";
|
||||
|
||||
private static readonly string[] RequiredCoreActions = { "Move", "Jump", "Crouch", "Prone", "Dash", "Walk", "Sprint" };
|
||||
|
||||
[SerializeField] private PlayerController targetController;
|
||||
private readonly List<ValidationIssue> _issues = new List<ValidationIssue>();
|
||||
private Vector2 _scroll;
|
||||
|
||||
[MenuItem("Tools/Character Controller/Validation Window")]
|
||||
public static void Open()
|
||||
{
|
||||
GetWindow<CharacterControllerValidationWindow>("CC Validator");
|
||||
}
|
||||
|
||||
public static void OpenFor(PlayerController controller)
|
||||
{
|
||||
CharacterControllerValidationWindow window = GetWindow<CharacterControllerValidationWindow>("CC Validator");
|
||||
window.targetController = controller;
|
||||
window.RebuildIssues();
|
||||
window.Repaint();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!targetController)
|
||||
targetController = Selection.activeGameObject ? Selection.activeGameObject.GetComponentInParent<PlayerController>() : null;
|
||||
RebuildIssues();
|
||||
}
|
||||
|
||||
private void OnSelectionChange()
|
||||
{
|
||||
if (!targetController && Selection.activeGameObject)
|
||||
{
|
||||
targetController = Selection.activeGameObject.GetComponentInParent<PlayerController>();
|
||||
RebuildIssues();
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
EditorGUILayout.LabelField("Motion Core Character Controller Validation", EditorStyles.boldLabel);
|
||||
EditorGUILayout.HelpBox("Checks the selected controller for common setup errors. Fix buttons only apply deterministic, reversible scene or prefab edits.", MessageType.Info);
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
targetController = (PlayerController)EditorGUILayout.ObjectField("Player Controller", targetController, typeof(PlayerController), true);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
RebuildIssues();
|
||||
|
||||
if (GUILayout.Button("Use Selection", GUILayout.Width(110f)))
|
||||
{
|
||||
targetController = Selection.activeGameObject ? Selection.activeGameObject.GetComponentInParent<PlayerController>() : null;
|
||||
RebuildIssues();
|
||||
}
|
||||
}
|
||||
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
if (GUILayout.Button("Scan"))
|
||||
RebuildIssues();
|
||||
|
||||
using (new EditorGUI.DisabledScope(!HasFixableIssues()))
|
||||
{
|
||||
if (GUILayout.Button("Apply Safe Fixes"))
|
||||
{
|
||||
ApplySafeFixes();
|
||||
RebuildIssues();
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Copy Report"))
|
||||
CopyValidationReport();
|
||||
}
|
||||
|
||||
EditorGUILayout.Space(8f);
|
||||
DrawIssues();
|
||||
}
|
||||
|
||||
private void DrawIssues()
|
||||
{
|
||||
_scroll = EditorGUILayout.BeginScrollView(_scroll);
|
||||
|
||||
if (_issues.Count == 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("No issues found for the selected controller.", MessageType.Info);
|
||||
EditorGUILayout.EndScrollView();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ValidationIssue issue in _issues)
|
||||
{
|
||||
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
|
||||
{
|
||||
EditorGUILayout.LabelField(issue.Title, EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField(issue.Description, EditorStyles.wordWrappedLabel);
|
||||
if (issue.Fix != null && GUILayout.Button(issue.FixLabel))
|
||||
{
|
||||
issue.Fix();
|
||||
RebuildIssues();
|
||||
GUIUtility.ExitGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndScrollView();
|
||||
}
|
||||
|
||||
private void RebuildIssues()
|
||||
{
|
||||
_issues.Clear();
|
||||
|
||||
if (!targetController)
|
||||
{
|
||||
_issues.Add(new ValidationIssue(
|
||||
"No PlayerController selected",
|
||||
"Select a GameObject with PlayerController, or press Use Selection after selecting the player root.",
|
||||
null));
|
||||
return;
|
||||
}
|
||||
|
||||
ValidateRequiredComponents();
|
||||
ValidateRigidbody();
|
||||
ValidateCapsule();
|
||||
ValidateLayerMasks();
|
||||
ValidateCoreInput();
|
||||
ValidateFpsInput();
|
||||
ValidateFpsCamera();
|
||||
ValidateCinemachineAdapters();
|
||||
ValidateAnimatorBridge();
|
||||
ValidateFpsDemoReferences();
|
||||
ValidateFpsParkourSettings();
|
||||
ValidateFpsDemoAssets();
|
||||
}
|
||||
|
||||
private void ValidateRequiredComponents()
|
||||
{
|
||||
GameObject gameObject = targetController.gameObject;
|
||||
SerializedObject controller = new SerializedObject(targetController);
|
||||
|
||||
if (!targetController.GetComponent<Rigidbody>())
|
||||
AddFix("Missing Rigidbody", "PlayerController needs a Rigidbody on the same GameObject.", () => AddComponentAndAssign<Rigidbody>(gameObject, controller, "<RigidBody>k__BackingField"));
|
||||
|
||||
if (!targetController.GetComponent<CapsuleCollider>())
|
||||
AddFix("Missing CapsuleCollider", "PlayerController needs a CapsuleCollider on the same GameObject.", () => AddComponentAndAssign<CapsuleCollider>(gameObject, controller, "<CapsuleCollider>k__BackingField"));
|
||||
|
||||
if (!targetController.GetComponent<InputHandler>())
|
||||
AddFix("Missing InputHandler", "PlayerController needs an InputHandler on the same GameObject.", () => AddComponentAndAssign<InputHandler>(gameObject, controller, "<InputHandler>k__BackingField"));
|
||||
|
||||
AssignMissingReference<Rigidbody>(controller, "<RigidBody>k__BackingField", targetController.GetComponent<Rigidbody>(), "Rigidbody reference is not assigned.");
|
||||
AssignMissingReference<CapsuleCollider>(controller, "<CapsuleCollider>k__BackingField", targetController.GetComponent<CapsuleCollider>(), "CapsuleCollider reference is not assigned.");
|
||||
AssignMissingReference<InputHandler>(controller, "<InputHandler>k__BackingField", targetController.GetComponent<InputHandler>(), "InputHandler reference is not assigned.");
|
||||
}
|
||||
|
||||
private void ValidateRigidbody()
|
||||
{
|
||||
Rigidbody body = targetController.GetComponent<Rigidbody>();
|
||||
if (!body)
|
||||
return;
|
||||
|
||||
if (!body.useGravity || body.isKinematic || !body.freezeRotation || body.interpolation == RigidbodyInterpolation.None)
|
||||
{
|
||||
AddFix(
|
||||
"Rigidbody settings are not production-safe",
|
||||
"Recommended settings: non-kinematic, Use Gravity on, Freeze Rotation on, Interpolate enabled.",
|
||||
() =>
|
||||
{
|
||||
Undo.RecordObject(body, "Fix Rigidbody Settings");
|
||||
body.isKinematic = false;
|
||||
body.useGravity = true;
|
||||
body.freezeRotation = true;
|
||||
body.interpolation = RigidbodyInterpolation.Interpolate;
|
||||
EditorUtility.SetDirty(body);
|
||||
});
|
||||
}
|
||||
|
||||
if (body.collisionDetectionMode == CollisionDetectionMode.Discrete)
|
||||
{
|
||||
AddFix(
|
||||
"Rigidbody uses Discrete collision detection",
|
||||
"Fast FPS controllers are less stable with Discrete collision detection. Continuous Dynamic is a safer default.",
|
||||
() =>
|
||||
{
|
||||
Undo.RecordObject(body, "Set Continuous Collision Detection");
|
||||
body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||
EditorUtility.SetDirty(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateCapsule()
|
||||
{
|
||||
CapsuleCollider capsule = targetController.GetComponent<CapsuleCollider>();
|
||||
if (!capsule)
|
||||
return;
|
||||
|
||||
if (capsule.radius <= 0f || capsule.height <= 0f || capsule.height < capsule.radius * 2f)
|
||||
{
|
||||
AddFix(
|
||||
"Capsule dimensions are invalid",
|
||||
"Capsule height must be at least twice the radius, and both values must be positive.",
|
||||
() =>
|
||||
{
|
||||
Undo.RecordObject(capsule, "Fix Capsule Dimensions");
|
||||
capsule.radius = Mathf.Max(0.25f, capsule.radius);
|
||||
capsule.height = Mathf.Max(1.8f, capsule.radius * 2f);
|
||||
capsule.center = new Vector3(capsule.center.x, capsule.height * 0.5f, capsule.center.z);
|
||||
EditorUtility.SetDirty(capsule);
|
||||
});
|
||||
}
|
||||
|
||||
if (targetController.CrouchCapsuleHeight >= capsule.height || targetController.ProneCapsuleHeight >= targetController.CrouchCapsuleHeight)
|
||||
{
|
||||
_issues.Add(new ValidationIssue(
|
||||
"Stance heights need review",
|
||||
"Expected Standing height > CrouchCapsuleHeight > ProneCapsuleHeight. Adjust the PlayerController stance fields or assign a motor preset.",
|
||||
null));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateLayerMasks()
|
||||
{
|
||||
SerializedObject controller = new SerializedObject(targetController);
|
||||
SerializedProperty ground = controller.FindProperty("<GroundLayerMask>k__BackingField");
|
||||
SerializedProperty stairs = controller.FindProperty("<StairsLayerMask>k__BackingField");
|
||||
|
||||
if (ground != null && ground.intValue == 0)
|
||||
{
|
||||
AddFix(
|
||||
"GroundLayerMask is empty",
|
||||
"Ground probes will not detect any surfaces.",
|
||||
() => SetLayerMask("<GroundLayerMask>k__BackingField", LayerMask.GetMask("Default")));
|
||||
}
|
||||
|
||||
if (stairs != null && stairs.intValue == 0)
|
||||
{
|
||||
AddFix(
|
||||
"StairsLayerMask is empty",
|
||||
"Step-up logic will not detect stair surfaces.",
|
||||
() =>
|
||||
{
|
||||
int mask = targetController.GroundLayerMask.value != 0 ? targetController.GroundLayerMask.value : LayerMask.GetMask("Default");
|
||||
SetLayerMask("<StairsLayerMask>k__BackingField", mask);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateCoreInput()
|
||||
{
|
||||
InputHandler inputHandler = targetController.GetComponent<InputHandler>();
|
||||
if (!inputHandler)
|
||||
return;
|
||||
|
||||
SerializedObject input = new SerializedObject(inputHandler);
|
||||
SerializedProperty assetProperty = input.FindProperty("movementActionsAsset");
|
||||
SerializedProperty mapProperty = input.FindProperty("movementActionMapName");
|
||||
InputActionAsset asset = assetProperty?.objectReferenceValue as InputActionAsset;
|
||||
string mapName = string.IsNullOrWhiteSpace(mapProperty?.stringValue) ? "Control" : mapProperty.stringValue;
|
||||
|
||||
if (!asset)
|
||||
{
|
||||
AddFix(
|
||||
"Core input asset is missing",
|
||||
"InputHandler requires a core movement input asset.",
|
||||
() => AssignInputAsset(inputHandler, "movementActionsAsset", AssetDatabase.LoadAssetAtPath<InputActionAsset>(CoreInputPath)));
|
||||
return;
|
||||
}
|
||||
|
||||
ValidateActionMap(asset, mapName, RequiredCoreActions, "Core input");
|
||||
}
|
||||
|
||||
private void ValidateAnimatorBridge()
|
||||
{
|
||||
Component bridge = FindComponentByTypeName(targetController.gameObject, "CharacterAnimatorBridge");
|
||||
if (!bridge)
|
||||
return;
|
||||
|
||||
SerializedObject serializedBridge = new SerializedObject(bridge);
|
||||
SerializedProperty parameters = serializedBridge.FindProperty("parameters");
|
||||
if (parameters != null && !parameters.objectReferenceValue)
|
||||
{
|
||||
AddFix(
|
||||
"Animator bridge parameter mapping is missing",
|
||||
"CharacterAnimatorBridge is optional, but when present it should reference a CharacterAnimatorParameters asset so animation integrations work without source edits.",
|
||||
() => AssignSerializedObjectReference(bridge, "parameters", AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(AnimatorParametersPath)));
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateCinemachineAdapters()
|
||||
{
|
||||
CharacterCinemachineAdapter[] adapters = FindCinemachineAdaptersInTargetScene();
|
||||
for (int i = 0; i < adapters.Length; i++)
|
||||
{
|
||||
CharacterCinemachineAdapter adapter = adapters[i];
|
||||
if (!adapter)
|
||||
continue;
|
||||
|
||||
PlayerController adapterController = adapter.PlayerController;
|
||||
if (adapterController && adapterController != targetController)
|
||||
continue;
|
||||
|
||||
if (!adapter.ValidateTargetBindings(out string message))
|
||||
{
|
||||
_issues.Add(new ValidationIssue(
|
||||
"Cinemachine adapter target binding needs review",
|
||||
$"{adapter.name}: {message} Assign a supported Cinemachine camera component or disable Follow/LookAt assignment on the adapter.",
|
||||
null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CharacterCinemachineAdapter[] FindCinemachineAdaptersInTargetScene()
|
||||
{
|
||||
if (!targetController || !targetController.gameObject.scene.IsValid())
|
||||
return Array.Empty<CharacterCinemachineAdapter>();
|
||||
|
||||
List<CharacterCinemachineAdapter> adapters = new List<CharacterCinemachineAdapter>();
|
||||
GameObject[] roots = targetController.gameObject.scene.GetRootGameObjects();
|
||||
for (int i = 0; i < roots.Length; i++)
|
||||
roots[i].GetComponentsInChildren(true, adapters);
|
||||
|
||||
return adapters.ToArray();
|
||||
}
|
||||
|
||||
private void ValidateActionMap(InputActionAsset asset, string mapName, string[] requiredActions, string label)
|
||||
{
|
||||
InputActionMap map = asset.FindActionMap(mapName, throwIfNotFound: false);
|
||||
if (map == null)
|
||||
{
|
||||
_issues.Add(new ValidationIssue(label + " map missing", $"Action map '{mapName}' was not found in '{asset.name}'.", null));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string actionName in requiredActions)
|
||||
{
|
||||
if (map.FindAction(actionName, throwIfNotFound: false) == null)
|
||||
_issues.Add(new ValidationIssue(label + " action missing", $"Action '{actionName}' was not found in map '{mapName}'.", null));
|
||||
}
|
||||
}
|
||||
|
||||
private InputActionAsset FindActionAssetWithMap(SerializedProperty arrayProperty, string mapName)
|
||||
{
|
||||
if (arrayProperty == null || !arrayProperty.isArray)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < arrayProperty.arraySize; i++)
|
||||
{
|
||||
InputActionAsset asset = arrayProperty.GetArrayElementAtIndex(i).objectReferenceValue as InputActionAsset;
|
||||
if (!asset)
|
||||
continue;
|
||||
|
||||
InputActionMap map = asset.FindActionMap(mapName, throwIfNotFound: false);
|
||||
if (map != null)
|
||||
return asset;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void AddFix(string title, string description, Action fix)
|
||||
{
|
||||
_issues.Add(new ValidationIssue(title, description, fix));
|
||||
}
|
||||
|
||||
private void AssignMissingReference<T>(SerializedObject controller, string propertyName, T component, string description) where T : Component
|
||||
{
|
||||
SerializedProperty property = controller.FindProperty(propertyName);
|
||||
if (property == null || property.objectReferenceValue || !component)
|
||||
return;
|
||||
|
||||
AddFix(typeof(T).Name + " reference is empty", description, () =>
|
||||
{
|
||||
controller.Update();
|
||||
SerializedProperty freshProperty = controller.FindProperty(propertyName);
|
||||
freshProperty.objectReferenceValue = component;
|
||||
controller.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(targetController);
|
||||
});
|
||||
}
|
||||
|
||||
private void AddComponentAndAssign<T>(GameObject gameObject, SerializedObject controller, string propertyName) where T : Component
|
||||
{
|
||||
Undo.RegisterCompleteObjectUndo(gameObject, "Add " + typeof(T).Name);
|
||||
T component = Undo.AddComponent<T>(gameObject);
|
||||
controller.Update();
|
||||
SerializedProperty property = controller.FindProperty(propertyName);
|
||||
if (property != null)
|
||||
property.objectReferenceValue = component;
|
||||
controller.ApplyModifiedProperties();
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private void SetLayerMask(string propertyName, int mask)
|
||||
{
|
||||
SerializedObject controller = new SerializedObject(targetController);
|
||||
controller.Update();
|
||||
SerializedProperty property = controller.FindProperty(propertyName);
|
||||
if (property != null)
|
||||
property.intValue = mask;
|
||||
controller.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(targetController);
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private void AssignInputAsset(InputHandler inputHandler, string propertyName, InputActionAsset asset)
|
||||
{
|
||||
if (!asset)
|
||||
{
|
||||
Debug.LogWarning("[MotionCore Validator] Default input asset was not found at " + CoreInputPath);
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedObject input = new SerializedObject(inputHandler);
|
||||
input.Update();
|
||||
SerializedProperty property = input.FindProperty(propertyName);
|
||||
if (property != null)
|
||||
property.objectReferenceValue = asset;
|
||||
input.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(inputHandler);
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private void AssignSerializedObjectReference(UnityEngine.Object target, string propertyName, UnityEngine.Object value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
Debug.LogWarning("[MotionCore Validator] Asset was not found for property '" + propertyName + "'.");
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(target);
|
||||
serializedObject.Update();
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property != null)
|
||||
property.objectReferenceValue = value;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorUtility.SetDirty(target);
|
||||
MarkSceneDirty();
|
||||
}
|
||||
|
||||
private void ApplySafeFixes()
|
||||
{
|
||||
ValidationIssue[] fixes = _issues.FindAll(issue => issue.Fix != null).ToArray();
|
||||
foreach (ValidationIssue issue in fixes)
|
||||
issue.Fix();
|
||||
}
|
||||
|
||||
private bool HasFixableIssues()
|
||||
{
|
||||
foreach (ValidationIssue issue in _issues)
|
||||
{
|
||||
if (issue.Fix != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CopyValidationReport()
|
||||
{
|
||||
string targetName = targetController ? targetController.name : "None";
|
||||
int fixableCount = 0;
|
||||
for (int i = 0; i < _issues.Count; i++)
|
||||
{
|
||||
if (_issues[i].Fix != null)
|
||||
fixableCount++;
|
||||
}
|
||||
|
||||
System.Text.StringBuilder builder = new System.Text.StringBuilder();
|
||||
builder.AppendLine("Motion Core Validation Report");
|
||||
builder.AppendLine("Target: " + targetName);
|
||||
builder.AppendLine("Unity: " + Application.unityVersion);
|
||||
builder.AppendLine("Issues: " + _issues.Count);
|
||||
builder.AppendLine("Fixable: " + fixableCount);
|
||||
|
||||
for (int i = 0; i < _issues.Count; i++)
|
||||
{
|
||||
builder.AppendLine();
|
||||
builder.AppendLine((i + 1) + ". " + _issues[i].Title);
|
||||
builder.AppendLine(_issues[i].Description);
|
||||
builder.AppendLine("Fixable: " + (_issues[i].Fix != null ? "Yes" : "No"));
|
||||
}
|
||||
|
||||
EditorGUIUtility.systemCopyBuffer = builder.ToString();
|
||||
}
|
||||
|
||||
private static Component FindComponentByTypeName(GameObject gameObject, string typeName)
|
||||
{
|
||||
Component[] components = gameObject.GetComponentsInChildren<Component>(true);
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (component && component.GetType().Name == typeName)
|
||||
return component;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void MarkSceneDirty()
|
||||
{
|
||||
if (targetController && !EditorUtility.IsPersistent(targetController))
|
||||
EditorSceneManager.MarkSceneDirty(targetController.gameObject.scene);
|
||||
}
|
||||
|
||||
private sealed class ValidationIssue
|
||||
{
|
||||
public ValidationIssue(string title, string description, Action fix)
|
||||
{
|
||||
Title = title;
|
||||
Description = description;
|
||||
Fix = fix;
|
||||
}
|
||||
|
||||
public string Title { get; }
|
||||
public string Description { get; }
|
||||
public Action Fix { get; }
|
||||
public string FixLabel => "Fix";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6c3c29ac05d4930b536cfc0e13da7d2
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterControllerValidationWindow.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "CharacterMovement.Core.Editor",
|
||||
"rootNamespace": "CharacterMovement.Editor",
|
||||
"references": [
|
||||
"CharacterMovement.Core",
|
||||
"Unity.InputSystem"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbe188d68da94db4582ac04865474e57
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CharacterMovement.Core.Editor.asmdef
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,263 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds a correctly configured MotionCore character.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One definition, used by both the shipped player prefab and the demo scene generator, so the
|
||||
/// two cannot drift apart. The tuning here is the asset's "sounds good out of the box" baseline:
|
||||
/// a character built from this should feel right before the user changes anything.
|
||||
/// </remarks>
|
||||
public static class CoreCharacterFactory
|
||||
{
|
||||
public const string PlayerPrefabPath = "Assets/Character Controller/Core/prefabs/Player.prefab";
|
||||
private const string InputActionsPath = "Assets/Character Controller/Core/Scripts/Input/Controls.inputactions";
|
||||
private const string AnimatorParametersPath =
|
||||
"Assets/Character Controller/Core/Data/DefaultCharacterAnimatorParameters.asset";
|
||||
|
||||
private const float CapsuleHeight = 1.8f;
|
||||
private const float CapsuleRadius = 0.3f;
|
||||
|
||||
[MenuItem("Tools/Character Controller/Rebuild Core Player Prefab")]
|
||||
public static void RebuildPlayerPrefab()
|
||||
{
|
||||
GameObject character = CreateCharacter("MotionCore Character");
|
||||
try
|
||||
{
|
||||
string directory = Path.GetDirectoryName(PlayerPrefabPath);
|
||||
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
PrefabUtility.SaveAsPrefabAsset(character, PlayerPrefabPath);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"[CharacterController] Rebuilt player prefab at '{PlayerPrefabPath}'.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(character);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Command-line entry point so the prefab can be rebuilt in CI.</summary>
|
||||
public static void RebuildPlayerPrefabFromCommandLine()
|
||||
{
|
||||
RebuildPlayerPrefab();
|
||||
EditorApplication.Exit(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a ready-to-play character in the current scene. The caller owns the result.
|
||||
/// </summary>
|
||||
public static GameObject CreateCharacter(string characterName)
|
||||
{
|
||||
GameObject root = new GameObject(characterName)
|
||||
{
|
||||
layer = 0
|
||||
};
|
||||
|
||||
if (InternalEditorTagExists("Player"))
|
||||
root.tag = "Player";
|
||||
|
||||
CreateVisual(root.transform);
|
||||
|
||||
Rigidbody rigidbody = root.AddComponent<Rigidbody>();
|
||||
rigidbody.mass = 70f;
|
||||
rigidbody.freezeRotation = true;
|
||||
rigidbody.useGravity = true;
|
||||
rigidbody.interpolation = RigidbodyInterpolation.Interpolate;
|
||||
rigidbody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
|
||||
|
||||
CapsuleCollider capsule = root.AddComponent<CapsuleCollider>();
|
||||
capsule.height = CapsuleHeight;
|
||||
capsule.radius = CapsuleRadius;
|
||||
capsule.center = new Vector3(0f, CapsuleHeight * 0.5f, 0f);
|
||||
|
||||
InputHandler inputHandler = root.AddComponent<InputHandler>();
|
||||
ConfigureInputHandler(inputHandler);
|
||||
|
||||
PlayerController controller = root.AddComponent<PlayerController>();
|
||||
ConfigureController(controller, rigidbody, inputHandler, capsule);
|
||||
|
||||
CharacterAnimatorBridge bridge = root.AddComponent<CharacterAnimatorBridge>();
|
||||
ConfigureAnimatorBridge(bridge, controller);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private static void CreateVisual(Transform parent)
|
||||
{
|
||||
GameObject visual = GameObject.CreatePrimitive(PrimitiveType.Capsule);
|
||||
visual.name = "Visual";
|
||||
visual.transform.SetParent(parent, false);
|
||||
visual.transform.localPosition = new Vector3(0f, CapsuleHeight * 0.5f, 0f);
|
||||
visual.transform.localScale = new Vector3(CapsuleRadius * 2f, CapsuleHeight * 0.5f, CapsuleRadius * 2f);
|
||||
|
||||
// The visual must not collide: grounding, step and clearance probes all use the capsule
|
||||
// on the root, and a second collider here would fight them.
|
||||
Object.DestroyImmediate(visual.GetComponent<Collider>());
|
||||
|
||||
GameObject facing = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
facing.name = "Forward Marker";
|
||||
facing.transform.SetParent(parent, false);
|
||||
facing.transform.localPosition = new Vector3(0f, CapsuleHeight * 0.75f, CapsuleRadius);
|
||||
facing.transform.localScale = new Vector3(0.12f, 0.12f, 0.2f);
|
||||
Object.DestroyImmediate(facing.GetComponent<Collider>());
|
||||
}
|
||||
|
||||
private static void ConfigureInputHandler(InputHandler inputHandler)
|
||||
{
|
||||
InputActionAsset inputAsset = AssetDatabase.LoadAssetAtPath<InputActionAsset>(InputActionsPath);
|
||||
if (!inputAsset)
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[CharacterController] Input actions not found at '{InputActionsPath}'. "
|
||||
+ "Assign an action asset on the InputHandler before playing.");
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedObject serialized = new SerializedObject(inputHandler);
|
||||
serialized.FindProperty("movementActionsAsset").objectReferenceValue = inputAsset;
|
||||
serialized.FindProperty("movementActionMapName").stringValue = "Control";
|
||||
serialized.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
private static void ConfigureController(
|
||||
PlayerController controller,
|
||||
Rigidbody rigidbody,
|
||||
InputHandler inputHandler,
|
||||
CapsuleCollider capsule)
|
||||
{
|
||||
SerializedObject serialized = new SerializedObject(controller);
|
||||
|
||||
SetObject(serialized, "<RigidBody>k__BackingField", rigidbody);
|
||||
SetObject(serialized, "<InputHandler>k__BackingField", inputHandler);
|
||||
SetObject(serialized, "<CapsuleCollider>k__BackingField", capsule);
|
||||
|
||||
// Movement
|
||||
SetFloat(serialized, "<Speed>k__BackingField", 5f);
|
||||
SetFloat(serialized, "<WalkSpeed>k__BackingField", 2.2f);
|
||||
SetFloat(serialized, "<GroundAcceleration>k__BackingField", 45f);
|
||||
SetFloat(serialized, "<GroundDeceleration>k__BackingField", 55f);
|
||||
SetFloat(serialized, "<RotationDamping>k__BackingField", 12f);
|
||||
|
||||
// Sprint
|
||||
SetEnum(serialized, "<SprintActivation>k__BackingField", (int)SprintActivationMode.Hold);
|
||||
SetFloat(serialized, "<SprintSpeed>k__BackingField", 8f);
|
||||
|
||||
// Jump: a ~1.6m jump with forgiving buffers and tap-to-hop height control.
|
||||
SetFloat(serialized, "<JumpingForce>k__BackingField", 6.5f);
|
||||
SetBool(serialized, "<VariableJumpHeight>k__BackingField", true);
|
||||
SetFloat(serialized, "<JumpCutMultiplier>k__BackingField", 0.45f);
|
||||
SetBool(serialized, "<CanMoveWhileJumping>k__BackingField", true);
|
||||
SetFloat(serialized, "<CoyoteTime>k__BackingField", 0.14f);
|
||||
SetFloat(serialized, "<JumpBufferTime>k__BackingField", 0.14f);
|
||||
SetFloat(serialized, "<ParkourBufferTime>k__BackingField", 0.14f);
|
||||
SetFloat(serialized, "<AirAcceleration>k__BackingField", 14f);
|
||||
SetFloat(serialized, "<AirDeceleration>k__BackingField", 2f);
|
||||
|
||||
// Gravity: a slightly heavy rise with a snappier fall reads as responsive rather than floaty.
|
||||
SetFloat(serialized, "<GravityScale>k__BackingField", 1.15f);
|
||||
SetFloat(serialized, "<FallGravityMultiplier>k__BackingField", 1.4f);
|
||||
SetFloat(serialized, "<MaxFallSpeed>k__BackingField", 30f);
|
||||
|
||||
// Stance
|
||||
SetFloat(serialized, "<CrouchSpeed>k__BackingField", 2.4f);
|
||||
SetFloat(serialized, "<ProneSpeed>k__BackingField", 1.2f);
|
||||
SetFloat(serialized, "<CrouchCapsuleHeight>k__BackingField", 1.15f);
|
||||
SetFloat(serialized, "<ProneCapsuleHeight>k__BackingField", 0.55f);
|
||||
SetFloat(serialized, "<StanceTransitionSpeed>k__BackingField", 14f);
|
||||
SetFloat(serialized, "<CeilingCheckDistance>k__BackingField", 0.05f);
|
||||
|
||||
// Ground detection
|
||||
SetInt(serialized, "<GroundLayerMask>k__BackingField", ~0);
|
||||
SetInt(serialized, "<StairsLayerMask>k__BackingField", ~0);
|
||||
SetFloat(serialized, "<GroundCheckDistance>k__BackingField", 0.15f);
|
||||
SetFloat(serialized, "<GroundProbeRadiusScale>k__BackingField", 0.95f);
|
||||
SetFloat(serialized, "<GroundSnapDistance>k__BackingField", 0.2f);
|
||||
SetFloat(serialized, "<GroundStickForce>k__BackingField", 24f);
|
||||
|
||||
// Slopes and steps
|
||||
SetFloat(serialized, "<MaxSlopeAngle>k__BackingField", 45f);
|
||||
SetFloat(serialized, "<MaxStairsAngle>k__BackingField", 60f);
|
||||
SetFloat(serialized, "<StepHeight>k__BackingField", 0.35f);
|
||||
SetFloat(serialized, "<StepCheckDistance>k__BackingField", 0.22f);
|
||||
SetFloat(serialized, "<StepProbeRadiusScale>k__BackingField", 0.85f);
|
||||
SetFloat(serialized, "<UphillSlopeSpeedMultiplier>k__BackingField", 0.9f);
|
||||
SetFloat(serialized, "<DownhillSlopeSpeedMultiplier>k__BackingField", 1.05f);
|
||||
SetFloat(serialized, "<SlideForce>k__BackingField", 15f);
|
||||
|
||||
// Upright is the neutral choice; turn this on for third-person characters that should
|
||||
// lean into slopes.
|
||||
SetBool(serialized, "<AlignToSlopeNormal>k__BackingField", false);
|
||||
SetFloat(serialized, "<Alignment>k__BackingField", 5f);
|
||||
|
||||
SetFloat(serialized, "<ExternalForceDrag>k__BackingField", 5f);
|
||||
|
||||
serialized.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
private static void ConfigureAnimatorBridge(CharacterAnimatorBridge bridge, PlayerController controller)
|
||||
{
|
||||
SerializedObject serialized = new SerializedObject(bridge);
|
||||
SetObject(serialized, "playerController", controller);
|
||||
|
||||
CharacterAnimatorParameters parameters =
|
||||
AssetDatabase.LoadAssetAtPath<CharacterAnimatorParameters>(AnimatorParametersPath);
|
||||
if (parameters)
|
||||
SetObject(serialized, "parameters", parameters);
|
||||
|
||||
serialized.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
private static bool InternalEditorTagExists(string tag)
|
||||
{
|
||||
foreach (string existing in UnityEditorInternal.InternalEditorUtility.tags)
|
||||
{
|
||||
if (existing == tag)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void SetFloat(SerializedObject serialized, string path, float value)
|
||||
{
|
||||
SerializedProperty property = serialized.FindProperty(path);
|
||||
if (property != null)
|
||||
property.floatValue = value;
|
||||
}
|
||||
|
||||
private static void SetInt(SerializedObject serialized, string path, int value)
|
||||
{
|
||||
SerializedProperty property = serialized.FindProperty(path);
|
||||
if (property != null)
|
||||
property.intValue = value;
|
||||
}
|
||||
|
||||
private static void SetEnum(SerializedObject serialized, string path, int value)
|
||||
{
|
||||
SerializedProperty property = serialized.FindProperty(path);
|
||||
if (property != null)
|
||||
property.enumValueIndex = value;
|
||||
}
|
||||
|
||||
private static void SetBool(SerializedObject serialized, string path, bool value)
|
||||
{
|
||||
SerializedProperty property = serialized.FindProperty(path);
|
||||
if (property != null)
|
||||
property.boolValue = value;
|
||||
}
|
||||
|
||||
private static void SetObject(SerializedObject serialized, string path, Object value)
|
||||
{
|
||||
SerializedProperty property = serialized.FindProperty(path);
|
||||
if (property != null)
|
||||
property.objectReferenceValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5cb6bf7ca4a4345ac838aed91ee774e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CoreCharacterFactory.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
public static class CoreDemoSceneVerifier
|
||||
{
|
||||
private const string ScenePath = "Assets/Character Controller/Core/Scenes/DemoScene.unity";
|
||||
|
||||
[MenuItem("Tools/Character Controller/Verify Core Demo Scene")]
|
||||
public static void Verify()
|
||||
{
|
||||
if (TryVerify(out string report))
|
||||
{
|
||||
Debug.Log(report);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogError(report);
|
||||
if (!Application.isBatchMode)
|
||||
EditorUtility.DisplayDialog("Core Demo Verification Failed", report, "OK");
|
||||
}
|
||||
|
||||
public static void VerifyFromCommandLine()
|
||||
{
|
||||
if (!TryVerify(out string report))
|
||||
throw new InvalidOperationException(report);
|
||||
|
||||
Debug.Log(report);
|
||||
}
|
||||
|
||||
private static bool TryVerify(out string report)
|
||||
{
|
||||
List<string> failures = new List<string>();
|
||||
if (!File.Exists(ScenePath))
|
||||
{
|
||||
failures.Add("Core demo scene file does not exist: " + ScenePath);
|
||||
report = BuildReport(failures);
|
||||
return false;
|
||||
}
|
||||
|
||||
Scene scene = EditorSceneManager.OpenScene(ScenePath, OpenSceneMode.Single);
|
||||
DemoSceneVerificationUtility.AddMissingScriptFailures(scene, failures);
|
||||
|
||||
ValidateRequiredObjects(scene, failures);
|
||||
ValidatePlayer(scene, failures);
|
||||
ValidateCamera(scene, failures);
|
||||
|
||||
report = BuildReport(failures);
|
||||
return failures.Count == 0;
|
||||
}
|
||||
|
||||
private static void ValidateRequiredObjects(Scene scene, IList<string> failures)
|
||||
{
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "Environment", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "Stairs", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "Ramp_Walkable", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "Slope_Steep", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "MovementGym", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "UnevenTerrain", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "LowCeiling", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "MovingPlatform_Test", failures, out GameObject movingPlatform);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "Step_TooHigh", failures, out _);
|
||||
DemoSceneVerificationUtility.RequireObject(scene, "HUD_Canvas", failures, out _);
|
||||
|
||||
if (movingPlatform)
|
||||
{
|
||||
DemoSceneVerificationUtility.RequireComponent(movingPlatform, "Core demo moving platform", failures, out MovingPlatform _);
|
||||
DemoSceneVerificationUtility.RequireComponent(movingPlatform, "Core demo moving platform", failures, out DemoMovingPlatformMover _);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidatePlayer(Scene scene, IList<string> failures)
|
||||
{
|
||||
if (!DemoSceneVerificationUtility.RequireObject(scene, "Player", failures, out GameObject player))
|
||||
return;
|
||||
|
||||
DemoSceneVerificationUtility.RequireComponent(player, "Core demo player", failures, out Rigidbody rigidbody);
|
||||
DemoSceneVerificationUtility.RequireComponent(player, "Core demo player", failures, out CapsuleCollider capsule);
|
||||
DemoSceneVerificationUtility.RequireComponent(player, "Core demo player", failures, out InputHandler inputHandler);
|
||||
DemoSceneVerificationUtility.RequireComponent(player, "Core demo player", failures, out DemoHudToggle _);
|
||||
|
||||
if (!DemoSceneVerificationUtility.RequireComponent(player, "Core demo player", failures, out PlayerController controller))
|
||||
return;
|
||||
|
||||
if (DemoSceneVerificationUtility.GetObjectReference(controller, "<RigidBody>k__BackingField") != rigidbody)
|
||||
failures.Add("Core demo PlayerController does not reference the generated Rigidbody.");
|
||||
|
||||
if (DemoSceneVerificationUtility.GetObjectReference(controller, "<InputHandler>k__BackingField") != inputHandler)
|
||||
failures.Add("Core demo PlayerController does not reference the generated InputHandler.");
|
||||
|
||||
if (DemoSceneVerificationUtility.GetObjectReference(controller, "<CapsuleCollider>k__BackingField") != capsule)
|
||||
failures.Add("Core demo PlayerController does not reference the generated CapsuleCollider.");
|
||||
|
||||
if (!DemoSceneVerificationUtility.GetObjectReference(controller, "<MotorSettings>k__BackingField"))
|
||||
failures.Add("Core demo PlayerController does not reference a CharacterMotorSettings preset.");
|
||||
|
||||
if (!DemoSceneVerificationUtility.GetObjectReference(inputHandler, "movementActionsAsset"))
|
||||
failures.Add("Core demo InputHandler does not reference Controls.inputactions.");
|
||||
|
||||
if (DemoSceneVerificationUtility.GetString(inputHandler, "movementActionMapName") != "Control")
|
||||
failures.Add("Core demo InputHandler is not configured for the Control action map.");
|
||||
}
|
||||
|
||||
private static void ValidateCamera(Scene scene, IList<string> failures)
|
||||
{
|
||||
if (!DemoSceneVerificationUtility.RequireObject(scene, "Main Camera", failures, out GameObject cameraObject))
|
||||
return;
|
||||
|
||||
DemoSceneVerificationUtility.RequireComponent(cameraObject, "Core demo camera", failures, out Camera _);
|
||||
if (!DemoSceneVerificationUtility.RequireComponent(cameraObject, "Core demo camera", failures, out CameraFollow follow))
|
||||
return;
|
||||
|
||||
if (!DemoSceneVerificationUtility.GetObjectReference(follow, "target"))
|
||||
failures.Add("Core demo CameraFollow target is not assigned.");
|
||||
}
|
||||
|
||||
private static string BuildReport(IReadOnlyList<string> failures)
|
||||
{
|
||||
if (failures.Count == 0)
|
||||
return "[CharacterController] Core demo scene verification passed.";
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.AppendLine("[CharacterController] Core demo scene verification failed:");
|
||||
for (int i = 0; i < failures.Count; i++)
|
||||
builder.Append("- ").AppendLine(failures[i]);
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dc7753c5b5bf67488050aed81209b9f
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/CoreDemoSceneVerifier.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,472 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.UI;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
|
||||
public static class DemoSceneSetup
|
||||
{
|
||||
|
||||
private const string MatGround = "Assets/Character Controller/Core/Materials/GridWhite_01_Mat.mat";
|
||||
private const string MatStairs = "Assets/Character Controller/Core/Materials/GridBlue_01_Mat.mat";
|
||||
private const string MatRamp = "Assets/Character Controller/Core/Materials/GridOrange_01_Mat.mat";
|
||||
private const string MatPlatform = "Assets/Character Controller/Core/Materials/GreyBlue_Mat.mat";
|
||||
private const string MatJump = "Assets/Character Controller/Core/Materials/Blue_Mat.mat";
|
||||
private const string ScenePath = "Assets/Character Controller/Core/Scenes/DemoScene.unity";
|
||||
private const string CoreInputPath = "Assets/Character Controller/Core/Scripts/Input/Controls.inputactions";
|
||||
private const string MotorSettingsPath = "Assets/Character Controller/Core/Data/ParkourLiteMotorSettings.asset";
|
||||
|
||||
private static Material _matGround, _matStairs, _matRamp, _matPlatform, _matJump;
|
||||
|
||||
[MenuItem("Tools/Character Controller/Build Demo Scene")]
|
||||
public static void Build()
|
||||
{
|
||||
BuildInternal(!Application.isBatchMode);
|
||||
}
|
||||
|
||||
public static void BuildFromCommandLine()
|
||||
{
|
||||
BuildInternal(false);
|
||||
}
|
||||
|
||||
private static void BuildInternal(bool interactive)
|
||||
{
|
||||
if (interactive && !EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
|
||||
return;
|
||||
|
||||
var scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
|
||||
|
||||
LoadMaterials();
|
||||
ConfigureLighting();
|
||||
|
||||
var env = new GameObject("Environment");
|
||||
|
||||
CreateGround(env.transform);
|
||||
CreateStairs(env.transform);
|
||||
CreateWalkableRamp(env.transform);
|
||||
CreateSteepSlope(env.transform);
|
||||
CreateLandingPlatform(env.transform);
|
||||
CreateJumpSection(env.transform);
|
||||
CreateMovementGym(env.transform);
|
||||
CreateWalls(env.transform);
|
||||
|
||||
var player = CreatePlayer();
|
||||
|
||||
ConfigureCamera(player.transform);
|
||||
|
||||
CreateHUD();
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(ScenePath)!);
|
||||
EditorSceneManager.SaveScene(scene, ScenePath);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
Debug.Log("[CharacterController] Demo scene saved to: " + ScenePath);
|
||||
if (interactive)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Done", "Demo scene built!\n\n" + ScenePath, "Open it");
|
||||
EditorSceneManager.OpenScene(ScenePath);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LoadMaterials()
|
||||
{
|
||||
_matGround = AssetDatabase.LoadAssetAtPath<Material>(MatGround);
|
||||
_matStairs = AssetDatabase.LoadAssetAtPath<Material>(MatStairs);
|
||||
_matRamp = AssetDatabase.LoadAssetAtPath<Material>(MatRamp);
|
||||
_matPlatform = AssetDatabase.LoadAssetAtPath<Material>(MatPlatform);
|
||||
_matJump = AssetDatabase.LoadAssetAtPath<Material>(MatJump);
|
||||
}
|
||||
|
||||
private static void ApplyMaterial(GameObject go, Material mat)
|
||||
{
|
||||
if (mat && go.TryGetComponent<Renderer>(out var r))
|
||||
r.sharedMaterial = mat;
|
||||
}
|
||||
|
||||
private static void ConfigureLighting()
|
||||
{
|
||||
var light = Object.FindAnyObjectByType<Light>();
|
||||
if (light)
|
||||
{
|
||||
light.transform.rotation = Quaternion.Euler(50f, -30f, 0f);
|
||||
light.intensity = 1.2f;
|
||||
light.shadows = LightShadows.Soft;
|
||||
}
|
||||
|
||||
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Flat;
|
||||
RenderSettings.ambientLight = new Color(0.25f, 0.28f, 0.35f);
|
||||
}
|
||||
|
||||
private static void CreateGround(Transform parent)
|
||||
{
|
||||
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
go.name = "Ground";
|
||||
go.transform.SetParent(parent);
|
||||
go.transform.position = new Vector3(0f, -0.25f, 5f);
|
||||
go.transform.localScale = new Vector3(30f, 0.5f, 28f);
|
||||
ApplyMaterial(go, _matGround);
|
||||
}
|
||||
|
||||
private static void CreateStairs(Transform parent)
|
||||
{
|
||||
const int steps = 10;
|
||||
const float stepH = 0.30f;
|
||||
const float stepD = 0.40f;
|
||||
const float stepW = 5.00f;
|
||||
const float startZ = 3.00f;
|
||||
|
||||
var root = new GameObject("Stairs");
|
||||
root.transform.SetParent(parent);
|
||||
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
float solidH = (i + 1) * stepH;
|
||||
float centerY = solidH * 0.5f;
|
||||
float centerZ = startZ + (i + 0.5f) * stepD;
|
||||
|
||||
var step = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
step.name = $"Step_{i:00}";
|
||||
step.transform.SetParent(root.transform);
|
||||
step.transform.position = new Vector3(0f, centerY, centerZ);
|
||||
step.transform.localScale = new Vector3(stepW, solidH, stepD);
|
||||
ApplyMaterial(step, _matStairs);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateLandingPlatform(Transform parent)
|
||||
{
|
||||
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
go.name = "LandingPlatform";
|
||||
go.transform.SetParent(parent);
|
||||
go.transform.position = new Vector3(0f, 3.25f, 9.5f);
|
||||
go.transform.localScale = new Vector3(7f, 0.5f, 5f);
|
||||
ApplyMaterial(go, _matPlatform);
|
||||
}
|
||||
|
||||
private static void CreateWalkableRamp(Transform parent)
|
||||
{
|
||||
const float rise = 3.0f;
|
||||
const float run = 6.43f;
|
||||
const float width = 5.0f;
|
||||
const float thick = 0.3f;
|
||||
|
||||
float slant = Mathf.Sqrt(rise * rise + run * run);
|
||||
float angle = Mathf.Atan2(rise, run) * Mathf.Rad2Deg;
|
||||
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
go.name = "Ramp_Walkable";
|
||||
go.transform.SetParent(parent);
|
||||
go.transform.position = new Vector3(8f, rise * 0.5f, 3f + run * 0.5f);
|
||||
go.transform.rotation = Quaternion.Euler(-angle, 0f, 0f);
|
||||
go.transform.localScale = new Vector3(width, thick, slant);
|
||||
ApplyMaterial(go, _matRamp);
|
||||
|
||||
CreateSignPost("Sign_WalkableRamp", new Vector3(8f, 4f, 3f),
|
||||
"WALKABLE\nRAMP ~25 deg", parent);
|
||||
}
|
||||
|
||||
private static void CreateSteepSlope(Transform parent)
|
||||
{
|
||||
const float rise = 3.0f;
|
||||
const float run = 2.35f;
|
||||
const float width = 5.0f;
|
||||
const float thick = 0.3f;
|
||||
|
||||
float slant = Mathf.Sqrt(rise * rise + run * run);
|
||||
float angle = Mathf.Atan2(rise, run) * Mathf.Rad2Deg;
|
||||
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
go.name = "Slope_Steep";
|
||||
go.transform.SetParent(parent);
|
||||
go.transform.position = new Vector3(-8f, rise * 0.5f, 3f + run * 0.5f);
|
||||
go.transform.rotation = Quaternion.Euler(-angle, 0f, 0f);
|
||||
go.transform.localScale = new Vector3(width, thick, slant);
|
||||
ApplyMaterial(go, _matRamp);
|
||||
|
||||
CreateSignPost("Sign_SteepSlope", new Vector3(-8f, 4f, 3f),
|
||||
"STEEP SLOPE\n~52 deg (SLIDES)", parent);
|
||||
}
|
||||
|
||||
private static void CreateJumpSection(Transform parent)
|
||||
{
|
||||
var root = new GameObject("JumpSection");
|
||||
root.transform.SetParent(parent);
|
||||
|
||||
var ledge = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
ledge.name = "Ledge";
|
||||
ledge.transform.SetParent(root.transform);
|
||||
ledge.transform.position = new Vector3(0f, 0.5f, -4f);
|
||||
ledge.transform.localScale = new Vector3(6f, 1f, 4f);
|
||||
ApplyMaterial(ledge, _matPlatform);
|
||||
|
||||
var near = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
near.name = "Platform_Jump";
|
||||
near.transform.SetParent(root.transform);
|
||||
near.transform.position = new Vector3(0f, 0f, -10f);
|
||||
near.transform.localScale = new Vector3(5f, 0.5f, 4f);
|
||||
ApplyMaterial(near, _matJump);
|
||||
|
||||
var far = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
far.name = "Platform_Dash";
|
||||
far.transform.SetParent(root.transform);
|
||||
far.transform.position = new Vector3(0f, 2f, -16f);
|
||||
far.transform.localScale = new Vector3(5f, 0.5f, 4f);
|
||||
ApplyMaterial(far, _matJump);
|
||||
|
||||
CreateSignPost("Sign_Jump", new Vector3(0f, 2f, -4f), "JUMP", root.transform);
|
||||
CreateSignPost("Sign_Dash", new Vector3(0f, 3f, -16f), "JUMP\n+ DASH", root.transform);
|
||||
}
|
||||
|
||||
private static void CreateMovementGym(Transform parent)
|
||||
{
|
||||
var root = new GameObject("MovementGym");
|
||||
root.transform.SetParent(parent);
|
||||
|
||||
CreateSignPost("Sign_MovementGym", new Vector3(10.5f, 2.2f, -6.5f),
|
||||
"MOVEMENT GYM\nUNEVEN / CEILING\nMOVING PLATFORM", root.transform);
|
||||
|
||||
CreateUnevenTerrain(root.transform);
|
||||
CreateLowCeiling(root.transform);
|
||||
CreateMovingPlatformLane(root.transform);
|
||||
CreateTooHighStep(root.transform);
|
||||
}
|
||||
|
||||
private static void CreateUnevenTerrain(Transform parent)
|
||||
{
|
||||
var root = new GameObject("UnevenTerrain");
|
||||
root.transform.SetParent(parent);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
float x = 7.6f + (i % 3) * 0.85f;
|
||||
float z = -5.4f + (i / 3) * 0.78f;
|
||||
float height = 0.06f + (i % 4) * 0.04f;
|
||||
|
||||
var block = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
block.name = $"Uneven_Block_{i + 1:00}";
|
||||
block.transform.SetParent(root.transform);
|
||||
block.transform.position = new Vector3(x, height * 0.5f, z);
|
||||
block.transform.localScale = new Vector3(0.72f, height, 0.68f);
|
||||
ApplyMaterial(block, _matGround);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateLowCeiling(Transform parent)
|
||||
{
|
||||
var floor = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
floor.name = "LowCeiling_Floor";
|
||||
floor.transform.SetParent(parent);
|
||||
floor.transform.position = new Vector3(12.5f, 0.03f, -2.5f);
|
||||
floor.transform.localScale = new Vector3(3.2f, 0.06f, 2.4f);
|
||||
ApplyMaterial(floor, _matGround);
|
||||
|
||||
var ceiling = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
ceiling.name = "LowCeiling";
|
||||
ceiling.transform.SetParent(parent);
|
||||
ceiling.transform.position = new Vector3(12.5f, 1.55f, -2.5f);
|
||||
ceiling.transform.localScale = new Vector3(3.2f, 0.16f, 2.4f);
|
||||
ApplyMaterial(ceiling, _matPlatform);
|
||||
|
||||
CreateSignPost("Sign_LowCeiling", new Vector3(12.5f, 2.1f, -4.1f),
|
||||
"CROUCH / PRONE\nSTAND BLOCKED", parent);
|
||||
}
|
||||
|
||||
private static void CreateMovingPlatformLane(Transform parent)
|
||||
{
|
||||
var platform = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
platform.name = "MovingPlatform_Test";
|
||||
platform.transform.SetParent(parent);
|
||||
platform.transform.position = new Vector3(10.5f, 0.1f, 2.5f);
|
||||
platform.transform.localScale = new Vector3(2.5f, 0.2f, 2f);
|
||||
ApplyMaterial(platform, _matPlatform);
|
||||
|
||||
var body = platform.AddComponent<Rigidbody>();
|
||||
body.useGravity = false;
|
||||
body.isKinematic = true;
|
||||
|
||||
platform.AddComponent<MovingPlatform>();
|
||||
|
||||
var mover = platform.AddComponent<DemoMovingPlatformMover>();
|
||||
mover.LocalOffset = new Vector3(0f, 0f, 3f);
|
||||
mover.Duration = 2.5f;
|
||||
|
||||
CreateSignPost("Sign_MovingPlatform", new Vector3(10.5f, 1.8f, 0.7f),
|
||||
"MOVING PLATFORM\nCARRY TEST", parent);
|
||||
}
|
||||
|
||||
private static void CreateTooHighStep(Transform parent)
|
||||
{
|
||||
var step = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
step.name = "Step_TooHigh";
|
||||
step.transform.SetParent(parent);
|
||||
step.transform.position = new Vector3(13.8f, 0.35f, 2.6f);
|
||||
step.transform.localScale = new Vector3(1.4f, 0.7f, 1f);
|
||||
ApplyMaterial(step, _matStairs);
|
||||
|
||||
CreateSignPost("Sign_TooHighStep", new Vector3(13.8f, 1.5f, 1.3f),
|
||||
"TOO HIGH\nSHOULD NOT STEP", parent);
|
||||
}
|
||||
|
||||
private static void CreateWalls(Transform parent)
|
||||
{
|
||||
var root = new GameObject("BoundaryWalls");
|
||||
root.transform.SetParent(parent);
|
||||
|
||||
CreateWall(root.transform, "Wall_North", new Vector3( 0f, 2f, 20f), new Vector3(30f, 4f, 0.5f));
|
||||
CreateWall(root.transform, "Wall_South", new Vector3( 0f, 2f, -10f), new Vector3(30f, 4f, 0.5f));
|
||||
CreateWall(root.transform, "Wall_East", new Vector3( 16f, 2f, 5f), new Vector3(0.5f, 4f, 32f));
|
||||
CreateWall(root.transform, "Wall_West", new Vector3(-16f, 2f, 5f), new Vector3(0.5f, 4f, 32f));
|
||||
}
|
||||
|
||||
private static void CreateWall(Transform parent, string wallName, Vector3 pos, Vector3 scale)
|
||||
{
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
go.name = wallName;
|
||||
go.transform.SetParent(parent);
|
||||
go.transform.position = pos;
|
||||
go.transform.localScale = scale;
|
||||
|
||||
if (go.TryGetComponent<Renderer>(out var r))
|
||||
r.enabled = false;
|
||||
}
|
||||
|
||||
private static void CreateSignPost(string goName, Vector3 pos, string text, Transform parent)
|
||||
{
|
||||
var sign = new GameObject(goName);
|
||||
sign.transform.SetParent(parent);
|
||||
sign.transform.position = pos;
|
||||
|
||||
var textGO = new GameObject("Label");
|
||||
textGO.transform.SetParent(sign.transform);
|
||||
textGO.transform.localPosition = Vector3.zero;
|
||||
textGO.transform.localRotation = Quaternion.identity;
|
||||
|
||||
var label = textGO.AddComponent<TextMesh>();
|
||||
label.text = text;
|
||||
label.font = ResolveDefaultFont();
|
||||
label.fontSize = 64;
|
||||
label.characterSize = 0.07f;
|
||||
label.anchor = TextAnchor.MiddleCenter;
|
||||
label.alignment = TextAlignment.Center;
|
||||
label.color = Color.white;
|
||||
}
|
||||
|
||||
private static GameObject CreatePlayer()
|
||||
{
|
||||
// Built by the same factory as the shipped prefab, so the demo always demonstrates the
|
||||
// configuration users actually get.
|
||||
GameObject player = CoreCharacterFactory.CreateCharacter("Player");
|
||||
|
||||
var motorSettings = AssetDatabase.LoadAssetAtPath<CharacterMotorSettings>(MotorSettingsPath);
|
||||
if (!motorSettings)
|
||||
throw new FileNotFoundException("Core demo motor settings asset is missing.", MotorSettingsPath);
|
||||
|
||||
var controller = player.GetComponent<PlayerController>();
|
||||
var so = new SerializedObject(controller);
|
||||
so.FindProperty("<MotorSettings>k__BackingField").objectReferenceValue = motorSettings;
|
||||
so.FindProperty("<GroundLayerMask>k__BackingField").intValue = LayerMask.GetMask("Default");
|
||||
so.FindProperty("<StairsLayerMask>k__BackingField").intValue = LayerMask.GetMask("Default");
|
||||
so.ApplyModifiedPropertiesWithoutUndo();
|
||||
|
||||
player.AddComponent<DemoHudToggle>();
|
||||
player.transform.position = new Vector3(0f, 0.05f, 0f);
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
private static void ConfigureCamera(Transform playerTransform)
|
||||
{
|
||||
|
||||
var cam = Camera.main;
|
||||
if (!cam)
|
||||
{
|
||||
var camGO = new GameObject("Main Camera");
|
||||
camGO.tag = "MainCamera";
|
||||
cam = camGO.AddComponent<Camera>();
|
||||
camGO.AddComponent<AudioListener>();
|
||||
}
|
||||
|
||||
var follow = cam.gameObject.GetComponent<CameraFollow>()
|
||||
?? cam.gameObject.AddComponent<CameraFollow>();
|
||||
|
||||
var so = new SerializedObject(follow);
|
||||
var prop = so.FindProperty("target");
|
||||
if (prop != null)
|
||||
{
|
||||
prop.objectReferenceValue = playerTransform;
|
||||
so.ApplyModifiedPropertiesWithoutUndo();
|
||||
}
|
||||
|
||||
cam.transform.position = new Vector3(0f, 5f, -8f);
|
||||
cam.transform.rotation = Quaternion.Euler(20f, 0f, 0f);
|
||||
}
|
||||
|
||||
private static void CreateHUD()
|
||||
{
|
||||
|
||||
var esSys = new GameObject("EventSystem");
|
||||
esSys.AddComponent<EventSystem>();
|
||||
if (!esSys.TryGetComponent<InputSystemUIInputModule>(out _))
|
||||
esSys.AddComponent<InputSystemUIInputModule>();
|
||||
|
||||
var canvasGO = new GameObject("HUD_Canvas");
|
||||
var canvas = canvasGO.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
|
||||
var scaler = canvasGO.AddComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
scaler.referenceResolution = new Vector2(1920f, 1080f);
|
||||
scaler.matchWidthOrHeight = 0.5f;
|
||||
|
||||
canvasGO.AddComponent<GraphicRaycaster>();
|
||||
|
||||
var labelGO = new GameObject("StateLabel");
|
||||
labelGO.transform.SetParent(canvasGO.transform, false);
|
||||
|
||||
var label = labelGO.AddComponent<Text>();
|
||||
label.text = "Runtime debug overlay is enabled by default";
|
||||
label.font = ResolveDefaultFont();
|
||||
label.fontSize = 28;
|
||||
label.color = Color.white;
|
||||
|
||||
var rect = label.rectTransform;
|
||||
rect.anchorMin = new Vector2(0f, 1f);
|
||||
rect.anchorMax = new Vector2(0f, 1f);
|
||||
rect.pivot = new Vector2(0f, 1f);
|
||||
rect.anchoredPosition = new Vector2(24f, -24f);
|
||||
rect.sizeDelta = new Vector2(620f, 60f);
|
||||
|
||||
var hintGO = new GameObject("ControlsHint");
|
||||
hintGO.transform.SetParent(canvasGO.transform, false);
|
||||
|
||||
var hint = hintGO.AddComponent<Text>();
|
||||
hint.text = "WASD - Move Shift - Sprint Alt - Walk\n" +
|
||||
"Space - Jump E - Dash Ctrl - Crouch\n" +
|
||||
"Mouse - Camera";
|
||||
hint.font = ResolveDefaultFont();
|
||||
hint.fontSize = 18;
|
||||
hint.color = new Color(1f, 1f, 1f, 0.7f);
|
||||
|
||||
var hintRect = hint.rectTransform;
|
||||
hintRect.anchorMin = new Vector2(0f, 0f);
|
||||
hintRect.anchorMax = new Vector2(0f, 0f);
|
||||
hintRect.pivot = new Vector2(0f, 0f);
|
||||
hintRect.anchoredPosition = new Vector2(24f, 24f);
|
||||
hintRect.sizeDelta = new Vector2(500f, 80f);
|
||||
}
|
||||
|
||||
private static Font ResolveDefaultFont()
|
||||
{
|
||||
return Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf")
|
||||
?? Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4190706f46fd5c5429635ce315991321
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/DemoSceneSetup.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,129 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
public static class DemoSceneVerificationUtility
|
||||
{
|
||||
public static GameObject FindObject(Scene scene, string objectName)
|
||||
{
|
||||
GameObject[] roots = scene.GetRootGameObjects();
|
||||
for (int i = 0; i < roots.Length; i++)
|
||||
{
|
||||
Transform[] transforms = roots[i].GetComponentsInChildren<Transform>(true);
|
||||
for (int j = 0; j < transforms.Length; j++)
|
||||
{
|
||||
if (transforms[j].name == objectName)
|
||||
return transforms[j].gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool RequireObject(Scene scene, string objectName, IList<string> failures, out GameObject gameObject)
|
||||
{
|
||||
gameObject = FindObject(scene, objectName);
|
||||
if (gameObject)
|
||||
return true;
|
||||
|
||||
failures.Add($"Missing required scene object '{objectName}'.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool RequireComponent<T>(GameObject gameObject, string label, IList<string> failures, out T component)
|
||||
where T : Component
|
||||
{
|
||||
component = gameObject ? gameObject.GetComponent<T>() : null;
|
||||
if (component)
|
||||
return true;
|
||||
|
||||
failures.Add($"{label} is missing required component {typeof(T).Name}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void AddMissingScriptFailures(Scene scene, IList<string> failures)
|
||||
{
|
||||
GameObject[] roots = scene.GetRootGameObjects();
|
||||
for (int i = 0; i < roots.Length; i++)
|
||||
{
|
||||
Transform[] transforms = roots[i].GetComponentsInChildren<Transform>(true);
|
||||
for (int j = 0; j < transforms.Length; j++)
|
||||
{
|
||||
Component[] components = transforms[j].GetComponents<Component>();
|
||||
for (int k = 0; k < components.Length; k++)
|
||||
{
|
||||
if (!components[k])
|
||||
failures.Add($"Missing script on {GetPath(transforms[j])}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object GetObjectReference(Object target, string propertyName)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
return property?.objectReferenceValue;
|
||||
}
|
||||
|
||||
public static string GetString(Object target, string propertyName)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
return property?.stringValue;
|
||||
}
|
||||
|
||||
public static int GetArraySize(Object target, string propertyName)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
return property != null && property.isArray ? property.arraySize : 0;
|
||||
}
|
||||
|
||||
public static Object GetArrayObjectReference(Object target, string propertyName, int index)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
if (property == null || !property.isArray || index < 0 || index >= property.arraySize)
|
||||
return null;
|
||||
|
||||
return property.GetArrayElementAtIndex(index).objectReferenceValue;
|
||||
}
|
||||
|
||||
public static bool GetBool(Object target, string propertyName)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
return property != null && property.boolValue;
|
||||
}
|
||||
|
||||
public static float GetFloat(Object target, string propertyName)
|
||||
{
|
||||
SerializedProperty property = FindProperty(target, propertyName);
|
||||
return property?.floatValue ?? 0f;
|
||||
}
|
||||
|
||||
public static string GetPath(Transform transform)
|
||||
{
|
||||
if (!transform)
|
||||
return "<null>";
|
||||
|
||||
string path = transform.name;
|
||||
Transform parent = transform.parent;
|
||||
while (parent)
|
||||
{
|
||||
path = parent.name + "/" + path;
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private static SerializedProperty FindProperty(Object target, string propertyName)
|
||||
{
|
||||
if (!target)
|
||||
return null;
|
||||
|
||||
SerializedObject serializedObject = new SerializedObject(target);
|
||||
return serializedObject.FindProperty(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af2c736a3495ccb42a7d371198631260
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/DemoSceneVerificationUtility.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using CharacterMovement;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
[CustomEditor(typeof(InputHandler))]
|
||||
public class InputHandlerEditor : UnityEditor.Editor
|
||||
{
|
||||
private readonly Dictionary<InputExtensionModule, bool> _foldouts = new();
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
var handler = (InputHandler)target;
|
||||
var extensions = handler.GetComponents<InputExtensionModule>();
|
||||
if (extensions.Length == 0) return;
|
||||
|
||||
EditorGUILayout.Space(8);
|
||||
|
||||
var headerStyle = new GUIStyle(EditorStyles.boldLabel) { fontSize = 11 };
|
||||
EditorGUILayout.LabelField("Input Extensions", headerStyle);
|
||||
EditorGUILayout.Space(2);
|
||||
|
||||
foreach (var extension in extensions)
|
||||
{
|
||||
if (!_foldouts.ContainsKey(extension))
|
||||
_foldouts[extension] = true;
|
||||
|
||||
string typeName = extension.GetType().Name;
|
||||
string label = ObjectNames.NicifyVariableName(typeName);
|
||||
|
||||
_foldouts[extension] = EditorGUILayout.Foldout(
|
||||
_foldouts[extension],
|
||||
label,
|
||||
true,
|
||||
EditorStyles.foldoutHeader);
|
||||
|
||||
var descriptionStyle = new GUIStyle(EditorStyles.miniLabel)
|
||||
{
|
||||
wordWrap = true,
|
||||
normal = { textColor = new Color(0.6f, 0.6f, 0.6f) }
|
||||
};
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.LabelField(
|
||||
"This extension reads actions from maps assigned to InputHandler assets.",
|
||||
descriptionStyle);
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
if (!_foldouts[extension])
|
||||
{
|
||||
EditorGUILayout.Space(2);
|
||||
continue;
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
var serializedExtension = new SerializedObject(extension);
|
||||
serializedExtension.Update();
|
||||
|
||||
var property = serializedExtension.GetIterator();
|
||||
property.NextVisible(true);
|
||||
while (property.NextVisible(false))
|
||||
EditorGUILayout.PropertyField(property, true);
|
||||
|
||||
serializedExtension.ApplyModifiedProperties();
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.Space(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6fb3056f51a6274a8c5bc1bf4b8c250
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/InputHandlerEditor.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,416 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Groups the controller's settings into collapsible sections, surfaces configuration problems
|
||||
/// as inline warnings, and shows live locomotion state during play.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sections are driven by the table below rather than by field declaration order, because the
|
||||
/// controller is a partial class split across several files and the compiler's field order is not
|
||||
/// something the inspector should depend on. Any serialized property not listed here still gets
|
||||
/// drawn, under "Other", so a new field can never silently become invisible.
|
||||
/// </remarks>
|
||||
[CustomEditor(typeof(PlayerController))]
|
||||
[CanEditMultipleObjects]
|
||||
public class PlayerControllerEditor : UnityEditor.Editor
|
||||
{
|
||||
private const string FoldoutPrefKey = "MotionCore.PlayerControllerEditor.Section.";
|
||||
|
||||
private static readonly (string Title, bool ExpandedByDefault, string[] Properties)[] Sections =
|
||||
{
|
||||
("References", true, new[]
|
||||
{
|
||||
"<RigidBody>k__BackingField",
|
||||
"<InputHandler>k__BackingField",
|
||||
"<CapsuleCollider>k__BackingField",
|
||||
"<PlayerAnimator>k__BackingField",
|
||||
}),
|
||||
("Preset", true, new[]
|
||||
{
|
||||
"<MotorSettings>k__BackingField",
|
||||
}),
|
||||
("Movement", true, new[]
|
||||
{
|
||||
"<Speed>k__BackingField",
|
||||
"<WalkSpeed>k__BackingField",
|
||||
"<GroundAcceleration>k__BackingField",
|
||||
"<GroundDeceleration>k__BackingField",
|
||||
"<RotationDamping>k__BackingField",
|
||||
}),
|
||||
("Sprint", true, new[]
|
||||
{
|
||||
"<AllowSprint>k__BackingField",
|
||||
"<SprintActivation>k__BackingField",
|
||||
"<SprintSpeed>k__BackingField",
|
||||
}),
|
||||
("Jump", true, new[]
|
||||
{
|
||||
"<AllowJump>k__BackingField",
|
||||
"<JumpingForce>k__BackingField",
|
||||
"<VariableJumpHeight>k__BackingField",
|
||||
"<JumpCutMultiplier>k__BackingField",
|
||||
"<CanMoveWhileJumping>k__BackingField",
|
||||
"<CoyoteTime>k__BackingField",
|
||||
"<JumpBufferTime>k__BackingField",
|
||||
"<ParkourBufferTime>k__BackingField",
|
||||
"<AirAcceleration>k__BackingField",
|
||||
"<AirDeceleration>k__BackingField",
|
||||
"<JumpGraceDuration>k__BackingField",
|
||||
}),
|
||||
("Gravity", true, new[]
|
||||
{
|
||||
"<GravityScale>k__BackingField",
|
||||
"<FallGravityMultiplier>k__BackingField",
|
||||
"<MaxFallSpeed>k__BackingField",
|
||||
}),
|
||||
("Crouch & Stance", false, new[]
|
||||
{
|
||||
"<AllowCrouch>k__BackingField",
|
||||
"<AllowProne>k__BackingField",
|
||||
"<CrouchSpeed>k__BackingField",
|
||||
"<ProneSpeed>k__BackingField",
|
||||
"<CrouchCapsuleHeight>k__BackingField",
|
||||
"<ProneCapsuleHeight>k__BackingField",
|
||||
"<StanceTransitionSpeed>k__BackingField",
|
||||
"<CeilingCheckDistance>k__BackingField",
|
||||
"<CeilingProbeRadiusScale>k__BackingField",
|
||||
"<StanceClearanceRadiusScale>k__BackingField",
|
||||
}),
|
||||
("Ground Detection", false, new[]
|
||||
{
|
||||
"<GroundLayerMask>k__BackingField",
|
||||
"<StairsLayerMask>k__BackingField",
|
||||
"<GroundCheckDistance>k__BackingField",
|
||||
"<GroundProbeRadiusScale>k__BackingField",
|
||||
"<GroundSnapDistance>k__BackingField",
|
||||
"<GroundStickForce>k__BackingField",
|
||||
"<UseSupplementaryGroundRays>k__BackingField",
|
||||
"<SupplementaryRaySpread>k__BackingField",
|
||||
"<GroundProbeLiftOffset>k__BackingField",
|
||||
"<GroundProbeEpsilon>k__BackingField",
|
||||
}),
|
||||
("Slopes & Steps", false, new[]
|
||||
{
|
||||
"<MaxSlopeAngle>k__BackingField",
|
||||
"<MaxStairsAngle>k__BackingField",
|
||||
"<StepHeight>k__BackingField",
|
||||
"<StepCheckDistance>k__BackingField",
|
||||
"<StepProbeRadiusScale>k__BackingField",
|
||||
"<UphillSlopeSpeedMultiplier>k__BackingField",
|
||||
"<DownhillSlopeSpeedMultiplier>k__BackingField",
|
||||
"<SlideForce>k__BackingField",
|
||||
"<AlignToSlopeNormal>k__BackingField",
|
||||
"<Alignment>k__BackingField",
|
||||
}),
|
||||
("Abilities: Dash", false, new[]
|
||||
{
|
||||
"<AllowDash>k__BackingField",
|
||||
"<DashDuration>k__BackingField",
|
||||
"<DashLength>k__BackingField",
|
||||
"<DashCooldownDuration>k__BackingField",
|
||||
"<AirDashDownwardBoost>k__BackingField",
|
||||
}),
|
||||
("Abilities: Slide", false, new[]
|
||||
{
|
||||
"<AllowSlide>k__BackingField",
|
||||
"<SlideDuration>k__BackingField",
|
||||
"<SlideStartSpeed>k__BackingField",
|
||||
"<SlideEndSpeed>k__BackingField",
|
||||
"<SlideSteeringStrength>k__BackingField",
|
||||
"<SlideCooldownDuration>k__BackingField",
|
||||
"<MinimumSlideInputSpeed>k__BackingField",
|
||||
"<MaxSlopeSlideSpeed>k__BackingField",
|
||||
}),
|
||||
("Abilities: Vault", false, new[]
|
||||
{
|
||||
"<AllowVault>k__BackingField",
|
||||
"<VaultDuration>k__BackingField",
|
||||
"<VaultArcHeight>k__BackingField",
|
||||
"<VaultCooldownDuration>k__BackingField",
|
||||
"<VaultForwardCheckDistance>k__BackingField",
|
||||
"<VaultLandingForwardOffset>k__BackingField",
|
||||
"<VaultMinHeight>k__BackingField",
|
||||
"<VaultMaxHeight>k__BackingField",
|
||||
"<VaultProbeRadiusScale>k__BackingField",
|
||||
"<VaultGroundOffset>k__BackingField",
|
||||
}),
|
||||
("Camera", false, new[]
|
||||
{
|
||||
"mainCameraTransform",
|
||||
"autoFindMainCamera",
|
||||
"mainCameraRefreshInterval",
|
||||
"lockCursorOnStart",
|
||||
}),
|
||||
("Advanced", false, new[]
|
||||
{
|
||||
"inputSourceBehaviour",
|
||||
"<ExternalForceDrag>k__BackingField",
|
||||
"movementEventSpeedThreshold",
|
||||
"<AirborneLaunchVelocityThreshold>k__BackingField",
|
||||
"<FallDetectionVelocityThreshold>k__BackingField",
|
||||
"<ConfigureRigidbodyOnStart>k__BackingField",
|
||||
"<RigidbodyInterpolation>k__BackingField",
|
||||
"<RigidbodyCollisionDetection>k__BackingField",
|
||||
}),
|
||||
("Debug", false, new[]
|
||||
{
|
||||
"_enableDebugTools",
|
||||
"_showDebugOverlay",
|
||||
"_stateLabel",
|
||||
"_drawGizmosWhenNotSelected",
|
||||
"_drawGroundProbeGizmos",
|
||||
"_drawStepUpGizmos",
|
||||
"_drawVelocityGizmos",
|
||||
"_drawMovementGizmos",
|
||||
"_drawSurfaceNormalGizmos",
|
||||
"_debugVectorScale",
|
||||
"_groundHitColor",
|
||||
"_groundMissColor",
|
||||
"_stepUpColor",
|
||||
"_velocityColor",
|
||||
"_movementColor",
|
||||
}),
|
||||
};
|
||||
|
||||
private readonly List<string> _validationErrors = new List<string>();
|
||||
private readonly List<string> _validationWarnings = new List<string>();
|
||||
private readonly List<string> _validationInfo = new List<string>();
|
||||
private readonly HashSet<string> _drawnProperties = new HashSet<string>();
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
DrawValidation();
|
||||
|
||||
_drawnProperties.Clear();
|
||||
_drawnProperties.Add("m_Script");
|
||||
|
||||
foreach ((string title, bool expandedByDefault, string[] properties) in Sections)
|
||||
DrawSection(title, expandedByDefault, properties);
|
||||
|
||||
DrawRemainingProperties();
|
||||
DrawRuntimeState();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DrawSection(string title, bool expandedByDefault, string[] propertyNames)
|
||||
{
|
||||
List<SerializedProperty> properties = new List<SerializedProperty>(propertyNames.Length);
|
||||
foreach (string propertyName in propertyNames)
|
||||
{
|
||||
// Properties can be absent behind compile flags (the TextMeshPro state label) or on
|
||||
// a future version of the controller. Skipping them keeps the inspector working.
|
||||
SerializedProperty property = serializedObject.FindProperty(propertyName);
|
||||
if (property == null)
|
||||
continue;
|
||||
|
||||
properties.Add(property);
|
||||
_drawnProperties.Add(propertyName);
|
||||
}
|
||||
|
||||
if (properties.Count == 0)
|
||||
return;
|
||||
|
||||
string prefKey = FoldoutPrefKey + title;
|
||||
bool expanded = EditorPrefs.GetBool(prefKey, expandedByDefault);
|
||||
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
bool nextExpanded = EditorGUILayout.Foldout(expanded, title, true, EditorStyles.foldoutHeader);
|
||||
if (nextExpanded != expanded)
|
||||
EditorPrefs.SetBool(prefKey, nextExpanded);
|
||||
|
||||
if (nextExpanded)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (SerializedProperty property in properties)
|
||||
EditorGUILayout.PropertyField(property, true);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawRemainingProperties()
|
||||
{
|
||||
List<SerializedProperty> remaining = new List<SerializedProperty>();
|
||||
SerializedProperty iterator = serializedObject.GetIterator();
|
||||
bool enterChildren = true;
|
||||
while (iterator.NextVisible(enterChildren))
|
||||
{
|
||||
enterChildren = false;
|
||||
if (!_drawnProperties.Contains(iterator.name))
|
||||
remaining.Add(iterator.Copy());
|
||||
}
|
||||
|
||||
if (remaining.Count == 0)
|
||||
return;
|
||||
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
EditorGUILayout.LabelField("Other", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (SerializedProperty property in remaining)
|
||||
EditorGUILayout.PropertyField(property, true);
|
||||
EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void DrawValidation()
|
||||
{
|
||||
_validationErrors.Clear();
|
||||
_validationWarnings.Clear();
|
||||
_validationInfo.Clear();
|
||||
|
||||
foreach (UnityEngine.Object targetObject in targets)
|
||||
{
|
||||
if (targetObject is PlayerController controller)
|
||||
Validate(controller);
|
||||
}
|
||||
|
||||
foreach (string message in _validationErrors)
|
||||
EditorGUILayout.HelpBox(message, MessageType.Error);
|
||||
foreach (string message in _validationWarnings)
|
||||
EditorGUILayout.HelpBox(message, MessageType.Warning);
|
||||
foreach (string message in _validationInfo)
|
||||
EditorGUILayout.HelpBox(message, MessageType.Info);
|
||||
|
||||
if (_validationErrors.Count > 0 || _validationWarnings.Count > 0 || _validationInfo.Count > 0)
|
||||
EditorGUILayout.Space(2f);
|
||||
}
|
||||
|
||||
private void Validate(PlayerController controller)
|
||||
{
|
||||
if (controller.GroundLayerMask.value == 0)
|
||||
{
|
||||
AddWarning("Ground Layer Mask is empty. The character will fall through the world "
|
||||
+ "unless it is set; Default is used as a fallback at runtime.");
|
||||
}
|
||||
|
||||
if (controller.SprintSpeed < controller.Speed)
|
||||
AddWarning("Sprint Speed is lower than Speed, so sprinting will slow the character down.");
|
||||
|
||||
if (controller.WalkSpeed > controller.Speed)
|
||||
AddWarning("Walk Speed is higher than Speed, so walking will be faster than running.");
|
||||
|
||||
if (controller.MaxStairsAngle < controller.MaxSlopeAngle)
|
||||
{
|
||||
AddWarning("Max Stairs Angle is below Max Slope Angle. Stairs are meant to be more "
|
||||
+ "forgiving than slopes, so this is usually the wrong way round.");
|
||||
}
|
||||
|
||||
CapsuleCollider capsule = controller.CapsuleCollider
|
||||
? controller.CapsuleCollider
|
||||
: controller.GetComponent<CapsuleCollider>();
|
||||
|
||||
if (!capsule)
|
||||
{
|
||||
AddInfo("No CapsuleCollider assigned. One will be added automatically at runtime, but "
|
||||
+ "assigning it lets the editor validate heights and clearances.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (controller.CrouchCapsuleHeight >= capsule.height)
|
||||
{
|
||||
AddWarning($"Crouch Capsule Height ({controller.CrouchCapsuleHeight:0.##}) is not "
|
||||
+ $"lower than the standing height ({capsule.height:0.##}), so crouching "
|
||||
+ "will not fit under anything the character cannot already walk under.");
|
||||
}
|
||||
|
||||
if (controller.ProneCapsuleHeight > controller.CrouchCapsuleHeight)
|
||||
AddWarning("Prone Capsule Height is taller than Crouch Capsule Height.");
|
||||
|
||||
if (controller.VaultMaxHeight >= capsule.height)
|
||||
{
|
||||
AddWarning("Vault Max Height is at or above the standing capsule height. Obstacles "
|
||||
+ "that tall should usually be climbed rather than vaulted.");
|
||||
}
|
||||
|
||||
if (controller.StepHeight > capsule.height * 0.5f)
|
||||
{
|
||||
AddWarning("Step Height is more than half the capsule height, which lets the "
|
||||
+ "character climb walls it should have to jump.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!controller.GetComponent<InputHandler>() && !controller.InputHandler)
|
||||
{
|
||||
AddInfo("No InputHandler found. One will be added automatically at runtime, or you can "
|
||||
+ "assign your own ICharacterInputSource under Advanced.");
|
||||
}
|
||||
|
||||
if (!controller.AllowJump && !controller.AllowCrouch && !controller.AllowSprint)
|
||||
{
|
||||
AddInfo("Sprint, jump and crouch are all disabled. This character can only walk, "
|
||||
+ "which is fine for NPCs but is usually a mistake on a player character.");
|
||||
}
|
||||
|
||||
if (controller.MotorSettings)
|
||||
{
|
||||
AddInfo($"A motor preset ('{controller.MotorSettings.name}') is assigned. It drives "
|
||||
+ "how movement feels (speeds, acceleration, jump arc, gravity, slopes, "
|
||||
+ "ground probing) and overwrites those fields on validate and on start. "
|
||||
+ "Edit the preset asset to change the feel, or clear the field to tune "
|
||||
+ "this character directly. Ability toggles such as Allow Jump and Allow "
|
||||
+ "Dash, and Sprint Activation, are deliberately not part of a preset, so "
|
||||
+ "they stay yours to set per character.");
|
||||
}
|
||||
}
|
||||
|
||||
private void AddError(string message)
|
||||
{
|
||||
if (!_validationErrors.Contains(message))
|
||||
_validationErrors.Add(message);
|
||||
}
|
||||
|
||||
private void AddWarning(string message)
|
||||
{
|
||||
if (!_validationWarnings.Contains(message))
|
||||
_validationWarnings.Add(message);
|
||||
}
|
||||
|
||||
private void AddInfo(string message)
|
||||
{
|
||||
if (!_validationInfo.Contains(message))
|
||||
_validationInfo.Add(message);
|
||||
}
|
||||
|
||||
private void DrawRuntimeState()
|
||||
{
|
||||
if (!Application.isPlaying || targets.Length != 1)
|
||||
return;
|
||||
|
||||
PlayerController controller = target as PlayerController;
|
||||
if (!controller)
|
||||
return;
|
||||
|
||||
EditorGUILayout.Space(4f);
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
EditorGUILayout.LabelField("Live State", EditorStyles.boldLabel);
|
||||
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
EditorGUILayout.EnumPopup("Movement State", controller.MovementState);
|
||||
EditorGUILayout.EnumPopup("Stance", controller.CurrentStance);
|
||||
EditorGUILayout.Toggle("Grounded", controller.IsGrounded());
|
||||
EditorGUILayout.FloatField("Ground Angle", controller.GroundAngle);
|
||||
EditorGUILayout.FloatField("Planar Speed", controller.GetPlanarSpeed());
|
||||
EditorGUILayout.FloatField("Vertical Velocity", controller.VerticalVelocity);
|
||||
EditorGUILayout.FloatField("Speed Multiplier", controller.EffectiveSpeedMultiplier);
|
||||
EditorGUILayout.IntField("Movement Modifiers", controller.MovementModifierCount);
|
||||
EditorGUILayout.TextField(
|
||||
"Blocked",
|
||||
controller.BlockedCapabilities == MovementCapability.None
|
||||
? "Nothing"
|
||||
: controller.BlockedCapabilities.ToString());
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
Repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 080b24f211064494a50c055951234b7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Editor/PlayerControllerEditor.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2088a5462c1646847883fa352585c81e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-272362022367997255
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 10
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Blue_Mat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.48507768, g: 0.67556465, b: 0.7830189, a: 1}
|
||||
- _Color: {r: 0.48507768, g: 0.6755646, b: 0.7830188, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fee1b2bdbe82acf429944aa6fad9ac46
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Materials/Blue_Mat.mat
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,140 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-6500655174697112917
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 10
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GreyBlue_Mat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _ENVIRONMENTREFLECTIONS_OFF
|
||||
m_InvalidKeywords:
|
||||
- _GLOSSYREFLECTIONS_OFF
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.477
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.477
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.5110952, g: 0.62652487, b: 0.6886792, a: 1}
|
||||
- _Color: {r: 0.51109517, g: 0.62652487, b: 0.6886792, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ad4caec643af244bb61c15ec2c8616e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Materials/GreyBlue_Mat.mat
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,140 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GridBlue_01_Mat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 2
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 2800000, guid: d1118dda59970a2449ee890fa247c4c5, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.477
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 0
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.477
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _XRMotionVectorsPass: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0.27038085, g: 0.6601244, b: 0.8773585, a: 1}
|
||||
- _Color: {r: 0.27038082, g: 0.66012436, b: 0.8773585, a: 1}
|
||||
- _EmissionColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
--- !u!114 &4889104241632654758
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 10
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01d87ccbcd0c19044aca32dae061699b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Materials/GridBlue_01_Mat.mat
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,72 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GridOrange_01_Mat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 2100000, guid: f5f7fae415e92c04ebae5f730a2d8b0e, type: 2}
|
||||
m_ModifiedSerializedProperties: 2
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
- _ENVIRONMENTREFLECTIONS_OFF
|
||||
m_InvalidKeywords:
|
||||
- _GLOSSYREFLECTIONS_OFF
|
||||
m_LightmapFlags: 2
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _EnvironmentReflections: 0
|
||||
- _Glossiness: 0.477
|
||||
- _GlossyReflections: 0
|
||||
- _OcclusionStrength: 0
|
||||
- _Smoothness: 0.477
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 0.5985916, b: 0, a: 1}
|
||||
- _Color: {r: 1, g: 0.5985916, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
--- !u!114 &4628965128947302990
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 10
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d271237c24e011a44a21d0f912d36c2b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Materials/GridOrange_01_Mat.mat
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,142 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-5788133031919579493
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 10
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GridWhite_01_Mat
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
- _ENVIRONMENTREFLECTIONS_OFF
|
||||
m_InvalidKeywords:
|
||||
- _GLOSSYREFLECTIONS_OFF
|
||||
m_LightmapFlags: 2
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 2800000, guid: d9c0dd5cdac07b145be73329e489869a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 2800000, guid: c5c221ed57a3bf6488f8eba0db28a004, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 2800000, guid: d4d6919451fe3e24388816386a6d15a4, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0.004, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.477
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 0
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.477
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _XRMotionVectorsPass: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5f7fae415e92c04ebae5f730a2d8b0e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Materials/GridWhite_01_Mat.mat
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,497 @@
|
||||
# MotionCore Basic
|
||||
|
||||
A Rigidbody character controller for Unity 6. Basic owns locomotion and the infrastructure around
|
||||
it: walking, sprinting, crouching, jumping, slopes, stairs, moving platforms, ground detection,
|
||||
animation hooks, events, and the extension points other systems plug into.
|
||||
|
||||
It is deliberately scoped. Basic does not contain combat, weapons, inventory, stats, or a gameplay
|
||||
camera — see [Extending MotionCore Basic](#extending-motioncore-basic) for where those live.
|
||||
|
||||
---
|
||||
|
||||
## Contents
|
||||
|
||||
- [Quick start](#quick-start)
|
||||
- [Requirements](#requirements)
|
||||
- [Configuration](#configuration)
|
||||
- [Architecture](#architecture)
|
||||
- [Reading character state](#reading-character-state)
|
||||
- [Events](#events)
|
||||
- [Extension points](#extension-points)
|
||||
- [Replacing the input source](#replacing-the-input-source)
|
||||
- [External forces](#external-forces)
|
||||
- [Moving platforms](#moving-platforms)
|
||||
- [Animation](#animation)
|
||||
- [Debugging](#debugging)
|
||||
- [Extending MotionCore Basic](#extending-motioncore-basic)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## Quick start
|
||||
|
||||
1. Drag `Core/prefabs/Player.prefab` into your scene.
|
||||
2. Make sure your ground has colliders and is included in the controller's **Ground Layer Mask**.
|
||||
3. Press Play.
|
||||
|
||||
WASD moves, Shift sprints, Space jumps, C crouches. The prefab ships with tuned defaults, so it
|
||||
should feel right before you change anything.
|
||||
|
||||
Two other ways in:
|
||||
|
||||
- **`Tools > Character Controller > Setup Wizard`** converts an existing GameObject (your own model,
|
||||
your own rig) into a working character.
|
||||
- **`Tools > Character Controller > Build Demo Scene`** generates a movement gym with stairs, ramps,
|
||||
steep slopes, uneven terrain, a low ceiling, a jump course, and a moving platform.
|
||||
|
||||
If something does not work, open `Tools > Character Controller > Validation Window`. It checks the
|
||||
common setup mistakes and offers one-click fixes.
|
||||
|
||||
---
|
||||
|
||||
## Requirements
|
||||
|
||||
- Unity 6000.0 or newer
|
||||
- Input System package (`com.unity.inputsystem`)
|
||||
- UI package (`com.unity.ugui`) for the demo HUD only
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Everything below lives on `PlayerController`, grouped into collapsible inspector sections. Every
|
||||
field has a tooltip; this section covers the ones worth understanding before you tune.
|
||||
|
||||
### Movement
|
||||
|
||||
`Speed` is the baseline ground speed. `Walk Speed` and `Sprint Speed` are **absolute target speeds**,
|
||||
not bonuses added to `Speed`.
|
||||
|
||||
`Ground Acceleration` and `Ground Deceleration` control how quickly the character reaches and leaves
|
||||
its target speed, in m/s². Higher is snappier. Deceleration slightly above acceleration makes
|
||||
stopping feel crisp rather than slippery.
|
||||
|
||||
### Sprint
|
||||
|
||||
`Sprint Activation` is `Hold` or `Toggle`. In toggle mode a press flips sprinting on and off, and
|
||||
releasing the movement input ends it — so the character does not silently sprint again the next time
|
||||
the player moves.
|
||||
|
||||
### Jump
|
||||
|
||||
`Jumping Force` is launch speed in m/s. Jump height is roughly `force² / (2 × gravity)`, so with the
|
||||
default gravity, a force of 6.5 gives about 1.6 m.
|
||||
|
||||
`Variable Jump Height` gives tap-versus-hold height control: releasing the jump button while rising
|
||||
scales the remaining upward speed by `Jump Cut Multiplier`. It needs an input source that reports
|
||||
`IsJumpHeld`. Jumps started from the buffer or from `TryJump()` always reach full height, so a
|
||||
scripted jump is never cut short.
|
||||
|
||||
`Coyote Time` keeps the jump available briefly after walking off a ledge. `Jump Buffer Time`
|
||||
remembers a press made just before landing and fires it on touchdown. Both default to values that
|
||||
feel forgiving without feeling floaty.
|
||||
|
||||
`Air Acceleration` and `Air Deceleration` are the airborne equivalents of the ground values. Low air
|
||||
deceleration preserves jump momentum; set `Can Move While Jumping` off for a fully committed jump.
|
||||
|
||||
### Gravity
|
||||
|
||||
`Gravity Scale` scales `Physics.gravity` for this character only, so you can make one character
|
||||
heavy without touching project physics.
|
||||
|
||||
`Fall Gravity Multiplier` adds extra gravity **only while falling**. Above 1 the descent is faster
|
||||
than the rise, which is what most action games want — it reads as responsive rather than floaty.
|
||||
Set it to 1 for a pure ballistic arc.
|
||||
|
||||
`Max Fall Speed` is terminal velocity. It keeps long drops controllable and stops fast falls from
|
||||
tunnelling through thin floors.
|
||||
|
||||
### Crouch and stance
|
||||
|
||||
Three stances: standing, crouching, prone. Each has its own speed and capsule height. The controller
|
||||
refuses to stand up into a ceiling, so a character crouched under a low overhang stays crouched
|
||||
until there is room.
|
||||
|
||||
### Ground detection
|
||||
|
||||
`Ground Check Distance` is how far below the feet still counts as grounded. This is the value to
|
||||
reach for if jumps feel mushy (too large) or the character flickers airborne on bumps (too small).
|
||||
|
||||
`Ground Snap Distance` pulls the character back onto the surface when walking over crests and down
|
||||
stairs, which is what stops the "launch off every step" problem. `Ground Stick Force` holds contact
|
||||
on slopes and platforms; it is never applied while rising, so it cannot eat a jump.
|
||||
|
||||
`Ground Layer Mask` must include your ground. `Stairs Layer Mask` is optional — colliders on it use
|
||||
the more forgiving `Max Stairs Angle`, which keeps stair noses walkable.
|
||||
|
||||
### Slopes and steps
|
||||
|
||||
`Max Slope Angle` is the steepest surface the character can stand on; anything steeper becomes a
|
||||
slide. `Step Height` is the tallest step it can climb without jumping.
|
||||
|
||||
`Align To Slope Normal` tilts the character to match the surface. It suits third-person characters
|
||||
leaning into a hill; leave it off for upright or first-person characters. The shipped prefab has it
|
||||
off.
|
||||
|
||||
### Abilities
|
||||
|
||||
Dash, slide and vault have their own sections, each with its own input action, cooldown and tuning.
|
||||
|
||||
Every optional ability has an **Allow** toggle: `Allow Sprint`, `Allow Jump`, `Allow Crouch`,
|
||||
`Allow Prone`, `Allow Dash`, `Allow Slide`, `Allow Vault`. Turning one off disables it for that
|
||||
character with no code and no component surgery — an NPC that only walks, or a game without prone,
|
||||
is a checkbox.
|
||||
|
||||
Design-time toggles and runtime modifiers resolve through the same gate, so
|
||||
`IsCapabilityAllowed(MovementCapability.Dash)` gives one answer whether dashing was switched off on
|
||||
the prefab or denied by a status effect this frame.
|
||||
|
||||
### Advanced
|
||||
|
||||
These exist so you never have to edit the controller to change a behaviour, but most projects will
|
||||
not touch them:
|
||||
|
||||
- `Jump Grace Duration` — the protected window after launch where ground stick, snapping and coyote
|
||||
refresh stay off. Raise it only if jumps are being swallowed.
|
||||
- `Use Supplementary Ground Rays`, `Supplementary Ray Spread`, `Ground Probe Lift Offset`,
|
||||
`Ground Probe Epsilon` — ground probe shape. Turning the extra rays off saves six raycasts per
|
||||
physics step on simple geometry.
|
||||
- `Ceiling Probe Radius Scale`, `Stance Clearance Radius Scale` — widths of the head and stand-up
|
||||
checks. Lower them slightly if the character refuses to stand in tight spaces it should fit.
|
||||
- `Airborne Launch Velocity Threshold`, `Fall Detection Velocity Threshold` — how much vertical
|
||||
speed counts as launched or falling.
|
||||
- `Configure Rigidbody On Start`, `Rigidbody Interpolation`, `Rigidbody Collision Detection` — turn
|
||||
the first off to keep whatever you configured on the Rigidbody yourself.
|
||||
- `Max Slope Slide Speed` — speed cap while sliding down slopes too steep to stand on.
|
||||
- `Air Dash Downward Boost` — downward slam when dashing out of a jump. 0 keeps the dash level.
|
||||
- `Vault Ground Offset` — how far above the landing surface a vault finishes.
|
||||
|
||||
### Presets
|
||||
|
||||
`Character Motor Settings` is a ScriptableObject holding a complete movement feel. Assign one and
|
||||
its values overwrite the controller's movement fields on validate and on start, so one asset can
|
||||
re-feel every character using it. Four starter presets ship in `Core/Data/`: Tactical FPS, Arcade
|
||||
FPS, Third-Person RPG, and Parkour Lite.
|
||||
|
||||
Leave the field empty to tune a character directly in the inspector.
|
||||
|
||||
**A preset owns how movement feels, not what the character can do.** It covers speeds,
|
||||
acceleration, the jump arc, gravity, slopes, stairs and the ground probe tuning. It deliberately
|
||||
does *not* cover the ability toggles or Sprint Activation, because a preset overwrites the
|
||||
controller every time it validates — anything stored in one could never be overridden per character.
|
||||
So "does this character have a dash?" stays a per-character decision, and swapping presets to try a
|
||||
different feel never silently adds or removes a verb from your game.
|
||||
|
||||
The four shipped presets differ most obviously in their jump arc:
|
||||
|
||||
| Preset | Jump | Fall gravity | Character |
|
||||
| --- | --- | --- | --- |
|
||||
| Tactical FPS | fixed height | 1.35 | deliberate, weighty landings |
|
||||
| Arcade FPS | tap-to-hop, cut to 45% | 1.6 | responsive and forgiving |
|
||||
| Parkour Lite | tap-to-hop, cut to 35% | 1.45 | momentum, precise platforming |
|
||||
| Third-Person RPG | fixed height | 1.2 | weighty, reads well against authored animation |
|
||||
|
||||
Fixed height is not a limitation — it is the right choice when jumps are animation-driven or when
|
||||
the game wants every jump to commit.
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
PlayerController (partial class, one file per responsibility)
|
||||
├─ .cs lifecycle, serialized configuration, update loop
|
||||
├─ .Movement.cs velocity solve, slope-following, speed targets
|
||||
├─ .Grounding.cs ground probe, snapping, stepping, platforms
|
||||
├─ .Stance.cs stand / crouch / prone and capsule resizing
|
||||
├─ .Actions.cs jump, coyote time, input buffers, jump cut
|
||||
├─ .Observability.cs locomotion state, events, read-only state
|
||||
├─ .Extensions.cs movement modifiers and capability gates
|
||||
├─ .Input.cs input source resolution, sprint activation
|
||||
├─ .Vaulting.cs vault target detection
|
||||
├─ .Camera.cs camera reference used to orient input
|
||||
├─ .Modules.cs SkillModule registration and ticking
|
||||
├─ .API.cs snapshots, gates, external forces
|
||||
└─ .Debug.cs overlay and gizmos
|
||||
|
||||
CharacterGroundProbe capsule sweep + supplementary rays, foot-relative distances
|
||||
CharacterMotorSettings movement feel preset
|
||||
InputHandler Input System binding, implements ICharacterInputSource
|
||||
CharacterAnimatorBridge publishes state to an Animator
|
||||
MovingPlatform marks a platform the character should ride
|
||||
```
|
||||
|
||||
Locomotion runs as a small state machine. Ground states (`IdleState`, `MovingState`,
|
||||
`CrouchingState`, `ProneState`, `PlayerSlideState`) implement `IGroundLocomotionState`; airborne and
|
||||
transient states (`JumpingState`, `FallingState`, `DashingState`, `SlidingState`, `VaultingState`)
|
||||
do not. All of them derive from `PlayerStateBase`.
|
||||
|
||||
**You should not need to reference those classes.** They are implementation detail and may change.
|
||||
Read `MovementState` instead — see below.
|
||||
|
||||
Each physics step runs in this order: movement modifiers are re-evaluated, the active state solves
|
||||
velocity, then the controller applies gravity, ground snapping, ground stick and platform motion.
|
||||
|
||||
---
|
||||
|
||||
## Reading character state
|
||||
|
||||
`PlayerController` exposes the character's state directly:
|
||||
|
||||
```csharp
|
||||
LocomotionState state = controller.MovementState; // Idle, Walking, Running, Sprinting,
|
||||
// Crouching, Prone, Jumping, Falling,
|
||||
// Sliding, Dashing, Vaulting, Custom
|
||||
bool grounded = controller.IsGrounded();
|
||||
bool airborne = controller.IsAirborne;
|
||||
Vector3 velocity = controller.CurrentVelocity;
|
||||
Vector3 planar = controller.PlanarVelocity;
|
||||
float vertical = controller.VerticalVelocity;
|
||||
Vector3 normal = controller.GroundNormal;
|
||||
float slope = controller.GroundAngle;
|
||||
bool walkable = controller.IsOnWalkableGround;
|
||||
PlayerStance stance = controller.CurrentStance;
|
||||
```
|
||||
|
||||
`LocomotionState` is the stable contract. `GetStateSnapshot()` returns the same information as one
|
||||
immutable struct when you want to capture or transmit it.
|
||||
|
||||
---
|
||||
|
||||
## Events
|
||||
|
||||
Subscribe instead of polling, and instead of modifying Basic:
|
||||
|
||||
```csharp
|
||||
controller.MovementStateChanged += (previous, next) => { };
|
||||
controller.Grounded += () => { }; // regained ground contact
|
||||
controller.LeftGround += () => { }; // jumped or walked off an edge
|
||||
controller.StartedMoving += () => { };
|
||||
controller.StoppedMoving += () => { };
|
||||
controller.SprintStarted += () => { };
|
||||
controller.SprintEnded += () => { };
|
||||
controller.CrouchStarted += () => { };
|
||||
controller.CrouchEnded += () => { };
|
||||
controller.JumpStarted += () => { };
|
||||
controller.Landed += () => { };
|
||||
controller.StanceChanged += (previous, next) => { };
|
||||
controller.SlideStarted += () => { };
|
||||
controller.SlideEnded += () => { };
|
||||
controller.VaultStarted += () => { };
|
||||
controller.VaultEnded += () => { };
|
||||
```
|
||||
|
||||
`Grounded` / `LeftGround` and `StartedMoving` / `StoppedMoving` fire once per transition, not once
|
||||
per frame. The movement threshold is configurable under **Advanced**.
|
||||
|
||||
---
|
||||
|
||||
## Extension points
|
||||
|
||||
This is how other systems influence movement **without editing Basic**.
|
||||
|
||||
Register an `ICharacterMovementModifier`. Each one can scale speed and deny capabilities; speed
|
||||
contributions multiply and denials combine, so the result never depends on registration order.
|
||||
|
||||
```csharp
|
||||
public sealed class StaminaGate : MonoBehaviour, ICharacterMovementModifier
|
||||
{
|
||||
[SerializeField] private PlayerController controller;
|
||||
[SerializeField] private Stamina stamina;
|
||||
|
||||
private void OnEnable() => controller.AddMovementModifier(this);
|
||||
private void OnDisable() => controller.RemoveMovementModifier(this);
|
||||
|
||||
public void ApplyMovementModifiers(ref CharacterMovementModifiers modifiers)
|
||||
{
|
||||
if (stamina.Current <= 0f)
|
||||
modifiers.Block(MovementCapability.Sprint);
|
||||
|
||||
if (stamina.Current < stamina.Max * 0.2f)
|
||||
modifiers.MultiplySpeed(0.8f);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For a value some other code toggles, skip the interface and take a handle:
|
||||
|
||||
```csharp
|
||||
_heavyArmor = controller.CreateMovementModifier("heavy armor");
|
||||
_heavyArmor.SpeedMultiplier = 0.75f;
|
||||
_heavyArmor.BlockedCapabilities = MovementCapability.Sprint;
|
||||
|
||||
// later
|
||||
controller.RemoveMovementModifier(_heavyArmor);
|
||||
```
|
||||
|
||||
Capabilities that can be denied: `Move`, `Sprint`, `Jump`, `Crouch`, `Prone`, `Slide`, `Dash`,
|
||||
`Vault`, `Look`.
|
||||
|
||||
Query the combined result:
|
||||
|
||||
```csharp
|
||||
controller.CanMove; // nothing is blocking locomotion
|
||||
controller.CanSprint;
|
||||
controller.IsCapabilityAllowed(MovementCapability.Jump);
|
||||
controller.EffectiveSpeedMultiplier; // SpeedMultiplier × all modifiers
|
||||
controller.BlockedCapabilities; // flags, for debug UI
|
||||
```
|
||||
|
||||
Modifiers whose owning component is destroyed stop contributing automatically, so a character can
|
||||
never be left permanently rooted by a deleted status effect.
|
||||
|
||||
`SkillModule` remains available for features that need their own update tick alongside the state
|
||||
machine — `DoubleJumpModule` is a worked example.
|
||||
|
||||
---
|
||||
|
||||
## Replacing the input source
|
||||
|
||||
Basic never reads key bindings. It reads `ICharacterInputSource`:
|
||||
|
||||
```csharp
|
||||
public interface ICharacterInputSource
|
||||
{
|
||||
Vector2 MoveDirection { get; }
|
||||
bool IsMoving { get; }
|
||||
bool IsSprinting { get; }
|
||||
bool IsWalking { get; }
|
||||
bool IsCrouching { get; }
|
||||
bool IsProne { get; }
|
||||
bool IsJumpHeld { get; }
|
||||
|
||||
event Action JumpPerformed;
|
||||
event Action DashPerformed;
|
||||
event Action CrouchPerformed;
|
||||
event Action PronePerformed;
|
||||
}
|
||||
```
|
||||
|
||||
`InputHandler` is the shipped implementation, bound to an Input System action map.
|
||||
|
||||
Action names are configurable on the `InputHandler` under **Action Names**, so your map can call
|
||||
them whatever you like — there is no need to rename your actions to match, and no code to edit.
|
||||
Clear a name to disable that input entirely. A named action that is missing from the map logs one
|
||||
warning naming the action and the map, which you can silence with `Warn On Missing Actions`.
|
||||
|
||||
To drive the character from AI, a replay, a network stream, or your own input stack, implement the
|
||||
interface and either assign the component to **Advanced > Input Source Behaviour** or call:
|
||||
|
||||
```csharp
|
||||
controller.SetInputSource(myInputSource); // null restores the default
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## External forces
|
||||
|
||||
Use these for knockback, explosions, launch pads and ability pushes:
|
||||
|
||||
```csharp
|
||||
controller.AddImpulse(direction * 12f); // survives locomotion, decays over time
|
||||
controller.SetExternalVelocity(windVelocity); // replaces rather than adds
|
||||
controller.ClearExternalVelocity();
|
||||
controller.Teleport(position, rotation);
|
||||
```
|
||||
|
||||
`AddImpulse` is the one you almost always want. It is tracked separately from locomotion velocity,
|
||||
so the character keeps steering normally while being pushed instead of having the push erased on the
|
||||
next physics step. It bleeds off at `External Force Drag`.
|
||||
|
||||
An upward impulse leaves the ground and enters the airborne state immediately.
|
||||
|
||||
`AddForce(force, mode)` is a raw Rigidbody passthrough. Its horizontal component is overwritten by
|
||||
locomotion on the next step, so it only suits continuous physics applied every step, or purely
|
||||
vertical forces.
|
||||
|
||||
---
|
||||
|
||||
## Moving platforms
|
||||
|
||||
Add a `MovingPlatform` component to any platform the character should ride. Translating and rotating
|
||||
platforms are both supported; the character inherits platform motion, keeps relative position under
|
||||
rotation, and carries sensible inherited velocity when jumping off.
|
||||
|
||||
A platform driven by a Rigidbody works without the component, but `MovingPlatform` gives more stable
|
||||
results for transform-driven platforms because it tracks the delta per fixed step.
|
||||
|
||||
---
|
||||
|
||||
## Animation
|
||||
|
||||
Basic works with no Animator at all. To drive one, add `CharacterAnimatorBridge` (already on the
|
||||
prefab) and assign a `CharacterAnimatorParameters` asset.
|
||||
|
||||
The bridge writes `Speed`, `PlanarSpeed`, `Forward`, `Strafe`, `IsGrounded`, `IsFalling`,
|
||||
`IsJumping`, `IsSprinting`, `IsCrouching`, `IsProne`, `IsSliding`, `Stance` and `MovementState`, and
|
||||
fires triggers for jump, land, slide and vault. Every parameter name is configurable on the asset,
|
||||
and the bridge silently skips parameters your controller does not declare — so you can wire up only
|
||||
the ones you use without console noise.
|
||||
|
||||
No locomotion state depends on an Animator state name.
|
||||
|
||||
---
|
||||
|
||||
## Debugging
|
||||
|
||||
Under **Debug** on the controller:
|
||||
|
||||
- an on-screen overlay with state, grounding, slope angle and velocity
|
||||
- scene gizmos for the ground probe, step-up probe, velocity, movement direction and surface normal
|
||||
|
||||
The inspector also shows a **Live State** panel during play with the locomotion state, ground angle,
|
||||
speeds, active speed multiplier and which capabilities are currently blocked.
|
||||
|
||||
Turn `Enable Debug Tools` off for release builds; the overlay and gizmo code then costs nothing.
|
||||
|
||||
---
|
||||
|
||||
## Extending MotionCore Basic
|
||||
|
||||
Basic is the locomotion foundation. Genre systems live in separate packages that build on it through
|
||||
the public API described above — they do not fork or patch Basic.
|
||||
|
||||
**MotionCore FPS** adds first-person gameplay: FPS camera and mouse look, weapon architecture,
|
||||
aiming and ADS, recoil, weapon sway, weapon switching, hitscan and projectile firing, reloading,
|
||||
interaction, damage and hit feedback, footsteps and surfaces, and an FPS parkour set.
|
||||
|
||||
**MotionCore RPG** adds RPG gameplay: an orbit and lock-on camera, combat and targeting, stats and
|
||||
attributes, health/mana/stamina, equipment and inventory, abilities, and RPG interaction patterns.
|
||||
|
||||
The boundary is consistent, and it is the same boundary your own code should use:
|
||||
|
||||
| Concern | Owner |
|
||||
| --- | --- |
|
||||
| `CanMove`, `CanSprint`, `MovementCapability`, speed multipliers | Basic |
|
||||
| Stamina emptying, so sprint is denied | Your game, or RPG |
|
||||
| Generic impulse API | Basic |
|
||||
| Explosion knockback values and falloff | Your game, or FPS |
|
||||
| `MovementState`, grounding, events | Basic |
|
||||
| Attack animation locking movement | Your game, or RPG |
|
||||
|
||||
If you find yourself wanting to edit Basic to add a gameplay rule, there is almost certainly an
|
||||
extension point for it — a modifier, an event, or the input source.
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**Character falls through the floor.** Ground Layer Mask does not include the floor's layer, or the
|
||||
floor has no collider.
|
||||
|
||||
**Jumps feel mushy or the character seems to float.** Ground Check Distance is too large for the
|
||||
capsule.
|
||||
|
||||
**Character flickers between grounded and falling on bumpy ground.** Increase Ground Snap Distance,
|
||||
or Ground Check Distance slightly.
|
||||
|
||||
**Character launches off stairs.** Ground Snap Distance is 0, or Step Height is smaller than the
|
||||
step.
|
||||
|
||||
**Cannot stand up from crouch.** There is geometry overhead. This is intentional; the check uses the
|
||||
standing capsule height.
|
||||
|
||||
**Character will not move.** No input source, the action map name does not match, or something has
|
||||
blocked `MovementCapability.Move` — check the Live State panel's "Blocked" row during play.
|
||||
|
||||
The full manual, including the FPS add-on, is at `Assets/Character Controller/MANUAL.md`.
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c55be0f6d6c78f4caf6056f027413c3
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/README.md
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e82216dc4d7614447a92c12886614879
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1e8bf5cc01b2e941a4a33e4b7b92ab1
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scenes/DemoScene.unity
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 163b9b33b5b10ca499d61aea8d684ffb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee2dcf4cd72c4e48a8b0153c89b3d2be
|
||||
timeCreated: 1701807598
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace CharacterMovement
|
||||
{
|
||||
/// <summary>
|
||||
/// Shared base for every <see cref="PlayerController"/> state.
|
||||
/// States hold the controller reference here instead of inheriting it from another concrete
|
||||
/// state, so an airborne or transient state is never mistaken for a ground locomotion state.
|
||||
/// </summary>
|
||||
public abstract class PlayerStateBase : State
|
||||
{
|
||||
protected readonly PlayerController _playerController;
|
||||
|
||||
protected PlayerStateBase(PlayerController playerController)
|
||||
{
|
||||
_playerController = playerController;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c7f24c5660744f4b2ada22bdf013725
|
||||
timeCreated: 1757808000
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Abstracts/PlayerStateBase.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
public abstract class SkillModule : MonoBehaviour
|
||||
{
|
||||
protected PlayerController PlayerController { get; private set; }
|
||||
|
||||
internal void Initialize(PlayerController controller)
|
||||
{
|
||||
PlayerController = controller;
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
internal void Cleanup()
|
||||
{
|
||||
OnCleanup();
|
||||
}
|
||||
|
||||
protected virtual void OnInitialize() { }
|
||||
protected virtual void OnCleanup() { }
|
||||
public virtual void UpdateModule(float deltaTime) { }
|
||||
public virtual void FixedUpdateModule(float deltaTime) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88e5dd8b58cb4cd40b185bc95c914321
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Abstracts/SkillModule.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace CharacterMovement
|
||||
{
|
||||
public abstract class State
|
||||
{
|
||||
public abstract void Enter();
|
||||
public abstract void UpdateState(float deltaTime);
|
||||
public abstract void FixedUpdateState(float deltaTime);
|
||||
public abstract void Exit();
|
||||
}
|
||||
|
||||
public interface IGroundLocomotionState { }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37357d512a844e1b9b0b8d2db672aad0
|
||||
timeCreated: 1701807122
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Abstracts/State.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
public abstract class StateController : MonoBehaviour
|
||||
{
|
||||
private State _currentState;
|
||||
public State CurrentState => _currentState;
|
||||
|
||||
public event Action<State, State> StateChanged;
|
||||
|
||||
public void SwitchState(State newState)
|
||||
{
|
||||
var previous = _currentState;
|
||||
_currentState?.Exit();
|
||||
_currentState = newState;
|
||||
_currentState?.Enter();
|
||||
StateChanged?.Invoke(previous, _currentState);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
PreStateUpdate(deltaTime);
|
||||
_currentState?.UpdateState(deltaTime);
|
||||
CustomUpdate(deltaTime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
float deltaTime = Time.fixedDeltaTime;
|
||||
PreStateFixedUpdate(deltaTime);
|
||||
_currentState?.FixedUpdateState(deltaTime);
|
||||
CustomFixedUpdate(deltaTime);
|
||||
}
|
||||
|
||||
public abstract void Move(Vector3 moveDirection, float deltaTime, float additionalSpeed = 0);
|
||||
|
||||
/// <summary>Runs before the active state's update, for data states are about to read.</summary>
|
||||
protected virtual void PreStateUpdate(float deltaTime) { }
|
||||
|
||||
/// <summary>Runs before the active state's fixed update, for data states are about to read.</summary>
|
||||
protected virtual void PreStateFixedUpdate(float deltaTime) { }
|
||||
|
||||
protected abstract void CustomUpdate(float deltaTime);
|
||||
protected abstract void CustomFixedUpdate(float deltaTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b692b9daa1058943ac92cf258d15008
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Abstracts/StateController.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2093622c41e344feb0fb78a49bba8849
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace CharacterMovement
|
||||
{
|
||||
public enum CharacterAnimationState
|
||||
{
|
||||
None = 0,
|
||||
Idle = 1,
|
||||
Moving = 2,
|
||||
Jumping = 3,
|
||||
Falling = 4,
|
||||
Crouching = 5,
|
||||
Prone = 6,
|
||||
Sliding = 7,
|
||||
Dashing = 8,
|
||||
Vaulting = 9,
|
||||
Parkour = 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30e61f43d67947beb1e1d757f9e9ad19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Animation/CharacterAnimationState.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,280 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
[AddComponentMenu("Character Controller/Core/Character Animator Bridge")]
|
||||
public class CharacterAnimatorBridge : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StanceChangedEvent : UnityEvent<PlayerStance, PlayerStance>
|
||||
{
|
||||
}
|
||||
|
||||
[Header("References")]
|
||||
[Tooltip("Controller to read state from. Found on this GameObject if left empty.")]
|
||||
[SerializeField] private PlayerController playerController;
|
||||
[Tooltip("Animator to drive. Searched for in children if left empty.")]
|
||||
[SerializeField] private Animator animator;
|
||||
[Tooltip("Asset mapping controller state to your Animator's parameter names.")]
|
||||
[SerializeField] private CharacterAnimatorParameters parameters;
|
||||
|
||||
[Header("Tuning")]
|
||||
[Tooltip("Smoothing applied to float parameters, in seconds. 0 writes raw values.")]
|
||||
[SerializeField, Min(0f)] private float floatDampTime = 0.08f;
|
||||
[Header("Events")]
|
||||
[Tooltip("Raised when a jump launches.")]
|
||||
[SerializeField] private UnityEvent jumpStarted;
|
||||
[Tooltip("Raised on touchdown.")]
|
||||
[SerializeField] private UnityEvent landed;
|
||||
[Tooltip("Raised when a slide begins.")]
|
||||
[SerializeField] private UnityEvent slideStarted;
|
||||
[Tooltip("Raised when a slide ends.")]
|
||||
[SerializeField] private UnityEvent slideEnded;
|
||||
[Tooltip("Raised when a vault begins.")]
|
||||
[SerializeField] private UnityEvent vaultStarted;
|
||||
[Tooltip("Raised when a vault ends.")]
|
||||
[SerializeField] private UnityEvent vaultEnded;
|
||||
[Tooltip("Raised when an add-on module reports a mantle starting.")]
|
||||
[SerializeField] private UnityEvent mantleStarted;
|
||||
[Tooltip("Raised when an add-on module reports a mantle ending.")]
|
||||
[SerializeField] private UnityEvent mantleEnded;
|
||||
[Tooltip("Raised when the stance changes, with the previous and new stance.")]
|
||||
[SerializeField] private StanceChangedEvent stanceChanged;
|
||||
|
||||
private readonly Dictionary<int, AnimatorControllerParameterType> _availableParameters =
|
||||
new Dictionary<int, AnimatorControllerParameterType>();
|
||||
|
||||
public PlayerController PlayerController => playerController;
|
||||
public Animator Animator => animator;
|
||||
public CharacterAnimatorParameters Parameters => parameters;
|
||||
public UnityEvent JumpStarted => jumpStarted;
|
||||
public UnityEvent Landed => landed;
|
||||
public UnityEvent SlideStarted => slideStarted;
|
||||
public UnityEvent SlideEnded => slideEnded;
|
||||
public UnityEvent VaultStarted => vaultStarted;
|
||||
public UnityEvent VaultEnded => vaultEnded;
|
||||
public UnityEvent MantleStarted => mantleStarted;
|
||||
public UnityEvent MantleEnded => mantleEnded;
|
||||
public StanceChangedEvent StanceChanged => stanceChanged;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
ResolveReferences();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ResolveReferences();
|
||||
CacheAnimatorParameters();
|
||||
Subscribe();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Unsubscribe();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
floatDampTime = Mathf.Max(0f, floatDampTime);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!playerController || !animator || !parameters)
|
||||
return;
|
||||
|
||||
float deltaTime = Time.deltaTime;
|
||||
Vector3 velocity = playerController.RigidBody ? playerController.RigidBody.linearVelocity : Vector3.zero;
|
||||
Vector3 planarVelocity = Vector3.ProjectOnPlane(velocity, Vector3.up);
|
||||
Vector2 moveInput = playerController.InputSource.MoveDirection;
|
||||
LocomotionState movementState = playerController.MovementState;
|
||||
|
||||
TrySetFloat(parameters.Speed, velocity.magnitude, deltaTime);
|
||||
float planarSpeed = planarVelocity.magnitude;
|
||||
TrySetFloat(parameters.PlanarSpeed, planarSpeed, deltaTime);
|
||||
TrySetFloat(parameters.NormalizedSpeed, ResolveNormalizedSpeed(planarSpeed), deltaTime);
|
||||
TrySetFloat(parameters.Forward, moveInput.y, deltaTime);
|
||||
TrySetFloat(parameters.Strafe, moveInput.x, deltaTime);
|
||||
TrySetBool(parameters.IsGrounded, playerController.IsGrounded());
|
||||
TrySetBool(parameters.IsFalling, movementState == LocomotionState.Falling);
|
||||
TrySetBool(parameters.IsJumping, movementState == LocomotionState.Jumping);
|
||||
TrySetBool(parameters.IsSprinting, playerController.IsSprintRequested);
|
||||
TrySetBool(parameters.IsCrouching, playerController.CurrentStance == PlayerStance.Crouching);
|
||||
TrySetBool(parameters.IsProne, playerController.CurrentStance == PlayerStance.Prone);
|
||||
TrySetBool(parameters.IsSliding, movementState == LocomotionState.Sliding);
|
||||
TrySetInt(parameters.Stance, (int)playerController.CurrentStance);
|
||||
TrySetInt(parameters.MovementState, (int)PlayerController.ToAnimationState(movementState));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Planar speed as a 0-1 fraction of the character's top speed, for blend trees.
|
||||
/// </summary>
|
||||
private float ResolveNormalizedSpeed(float planarSpeed)
|
||||
{
|
||||
float topSpeed = Mathf.Max(playerController.SprintSpeed, playerController.Speed);
|
||||
return topSpeed > 0.0001f ? Mathf.Clamp01(planarSpeed / topSpeed) : 0f;
|
||||
}
|
||||
|
||||
public void RefreshAnimatorParameterCache()
|
||||
{
|
||||
CacheAnimatorParameters();
|
||||
}
|
||||
|
||||
private void ResolveReferences()
|
||||
{
|
||||
if (!playerController)
|
||||
playerController = GetComponent<PlayerController>();
|
||||
|
||||
if (!animator)
|
||||
{
|
||||
if (playerController && playerController.PlayerAnimator)
|
||||
animator = playerController.PlayerAnimator;
|
||||
else
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
}
|
||||
}
|
||||
|
||||
private void Subscribe()
|
||||
{
|
||||
if (!playerController)
|
||||
return;
|
||||
|
||||
playerController.JumpStarted += OnJumpStarted;
|
||||
playerController.Landed += OnLanded;
|
||||
playerController.SlideStarted += OnSlideStarted;
|
||||
playerController.SlideEnded += OnSlideEnded;
|
||||
playerController.VaultStarted += OnVaultStarted;
|
||||
playerController.VaultEnded += OnVaultEnded;
|
||||
playerController.MantleStarted += OnMantleStarted;
|
||||
playerController.MantleEnded += OnMantleEnded;
|
||||
playerController.StanceChanged += OnStanceChanged;
|
||||
}
|
||||
|
||||
private void Unsubscribe()
|
||||
{
|
||||
if (!playerController)
|
||||
return;
|
||||
|
||||
playerController.JumpStarted -= OnJumpStarted;
|
||||
playerController.Landed -= OnLanded;
|
||||
playerController.SlideStarted -= OnSlideStarted;
|
||||
playerController.SlideEnded -= OnSlideEnded;
|
||||
playerController.VaultStarted -= OnVaultStarted;
|
||||
playerController.VaultEnded -= OnVaultEnded;
|
||||
playerController.MantleStarted -= OnMantleStarted;
|
||||
playerController.MantleEnded -= OnMantleEnded;
|
||||
playerController.StanceChanged -= OnStanceChanged;
|
||||
}
|
||||
|
||||
private void CacheAnimatorParameters()
|
||||
{
|
||||
_availableParameters.Clear();
|
||||
if (!animator)
|
||||
return;
|
||||
|
||||
AnimatorControllerParameter[] animatorParameters = animator.parameters;
|
||||
for (int i = 0; i < animatorParameters.Length; i++)
|
||||
{
|
||||
AnimatorControllerParameter parameter = animatorParameters[i];
|
||||
_availableParameters[parameter.nameHash] = parameter.type;
|
||||
}
|
||||
}
|
||||
|
||||
private void TrySetFloat(string parameterName, float value, float deltaTime)
|
||||
{
|
||||
if (!TryGetParameter(parameterName, AnimatorControllerParameterType.Float, out int hash))
|
||||
return;
|
||||
|
||||
if (floatDampTime > 0f)
|
||||
animator.SetFloat(hash, value, floatDampTime, deltaTime);
|
||||
else
|
||||
animator.SetFloat(hash, value);
|
||||
}
|
||||
|
||||
private void TrySetBool(string parameterName, bool value)
|
||||
{
|
||||
if (TryGetParameter(parameterName, AnimatorControllerParameterType.Bool, out int hash))
|
||||
animator.SetBool(hash, value);
|
||||
}
|
||||
|
||||
private void TrySetInt(string parameterName, int value)
|
||||
{
|
||||
if (TryGetParameter(parameterName, AnimatorControllerParameterType.Int, out int hash))
|
||||
animator.SetInteger(hash, value);
|
||||
}
|
||||
|
||||
private void TrySetTrigger(string parameterName)
|
||||
{
|
||||
if (TryGetParameter(parameterName, AnimatorControllerParameterType.Trigger, out int hash))
|
||||
animator.SetTrigger(hash);
|
||||
}
|
||||
|
||||
private bool TryGetParameter(string parameterName, AnimatorControllerParameterType expectedType, out int hash)
|
||||
{
|
||||
hash = 0;
|
||||
if (string.IsNullOrWhiteSpace(parameterName) || !animator)
|
||||
return false;
|
||||
|
||||
hash = Animator.StringToHash(parameterName);
|
||||
return _availableParameters.TryGetValue(hash, out AnimatorControllerParameterType actualType)
|
||||
&& actualType == expectedType;
|
||||
}
|
||||
|
||||
private void OnJumpStarted()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.JumpStarted : null);
|
||||
jumpStarted?.Invoke();
|
||||
}
|
||||
|
||||
private void OnLanded()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.Landed : null);
|
||||
landed?.Invoke();
|
||||
}
|
||||
|
||||
private void OnSlideStarted()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.SlideStarted : null);
|
||||
slideStarted?.Invoke();
|
||||
}
|
||||
|
||||
private void OnSlideEnded()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.SlideEnded : null);
|
||||
slideEnded?.Invoke();
|
||||
}
|
||||
|
||||
private void OnVaultStarted()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.VaultStarted : null);
|
||||
vaultStarted?.Invoke();
|
||||
}
|
||||
|
||||
private void OnVaultEnded()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.VaultEnded : null);
|
||||
vaultEnded?.Invoke();
|
||||
}
|
||||
|
||||
private void OnMantleStarted()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.MantleStarted : null);
|
||||
mantleStarted?.Invoke();
|
||||
}
|
||||
|
||||
private void OnMantleEnded()
|
||||
{
|
||||
TrySetTrigger(parameters ? parameters.MantleEnded : null);
|
||||
mantleEnded?.Invoke();
|
||||
}
|
||||
|
||||
private void OnStanceChanged(PlayerStance previousStance, PlayerStance nextStance)
|
||||
{
|
||||
stanceChanged?.Invoke(previousStance, nextStance);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2afa0f6808a4a2a86b4ef67fb9e913b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Animation/CharacterAnimatorBridge.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Character Controller/Core/Animator Parameters", fileName = "CharacterAnimatorParameters")]
|
||||
public class CharacterAnimatorParameters : ScriptableObject
|
||||
{
|
||||
[Header("Float Parameters")]
|
||||
[SerializeField] private string speed = "Speed";
|
||||
[SerializeField] private string planarSpeed = "PlanarSpeed";
|
||||
[SerializeField]
|
||||
[Tooltip("Planar speed as 0-1 of the character's top speed. Convenient as the blend "
|
||||
+ "parameter of an idle/walk/run/sprint blend tree.")]
|
||||
private string normalizedSpeed = "NormalizedSpeed";
|
||||
[SerializeField] private string forward = "Forward";
|
||||
[Tooltip("Float parameter receiving sideways move input, -1 to 1.")]
|
||||
[SerializeField] private string strafe = "Strafe";
|
||||
|
||||
[Header("Bool Parameters")]
|
||||
[Tooltip("Bool parameter set while the character is on the ground.")]
|
||||
[SerializeField] private string isGrounded = "IsGrounded";
|
||||
[Tooltip("Bool parameter set while the character is falling.")]
|
||||
[SerializeField] private string isFalling = "IsFalling";
|
||||
[Tooltip("Bool parameter set while the character is rising from a jump.")]
|
||||
[SerializeField] private string isJumping = "IsJumping";
|
||||
[Tooltip("Bool parameter set while sprinting.")]
|
||||
[SerializeField] private string isSprinting = "IsSprinting";
|
||||
[Tooltip("Bool parameter set while in the crouch stance.")]
|
||||
[SerializeField] private string isCrouching = "IsCrouching";
|
||||
[Tooltip("Bool parameter set while in the prone stance.")]
|
||||
[SerializeField] private string isProne = "IsProne";
|
||||
[Tooltip("Bool parameter set while sliding.")]
|
||||
[SerializeField] private string isSliding = "IsSliding";
|
||||
|
||||
[Header("Int Parameters")]
|
||||
[Tooltip("Int parameter receiving the PlayerStance value (0 standing, 1 crouching, 2 prone).")]
|
||||
[SerializeField] private string stance = "Stance";
|
||||
[Tooltip("Int parameter receiving the CharacterAnimationState value.")]
|
||||
[SerializeField] private string movementState = "MovementState";
|
||||
|
||||
[Header("Trigger Parameters")]
|
||||
[Tooltip("Trigger fired when a jump launches.")]
|
||||
[SerializeField] private string jumpStarted = "JumpStarted";
|
||||
[Tooltip("Trigger fired on touchdown.")]
|
||||
[SerializeField] private string landed = "Landed";
|
||||
[Tooltip("Trigger fired when a slide begins.")]
|
||||
[SerializeField] private string slideStarted = "SlideStarted";
|
||||
[Tooltip("Trigger fired when a slide ends.")]
|
||||
[SerializeField] private string slideEnded = "SlideEnded";
|
||||
[Tooltip("Trigger fired when a vault begins.")]
|
||||
[SerializeField] private string vaultStarted = "VaultStarted";
|
||||
[Tooltip("Trigger fired when a vault ends.")]
|
||||
[SerializeField] private string vaultEnded = "VaultEnded";
|
||||
[Tooltip("Trigger fired when an add-on module reports a mantle starting.")]
|
||||
[SerializeField] private string mantleStarted = "MantleStarted";
|
||||
[Tooltip("Trigger fired when an add-on module reports a mantle ending.")]
|
||||
[SerializeField] private string mantleEnded = "MantleEnded";
|
||||
|
||||
public string Speed => speed;
|
||||
public string PlanarSpeed => planarSpeed;
|
||||
public string NormalizedSpeed => normalizedSpeed;
|
||||
public string Forward => forward;
|
||||
public string Strafe => strafe;
|
||||
public string IsGrounded => isGrounded;
|
||||
public string IsFalling => isFalling;
|
||||
public string IsJumping => isJumping;
|
||||
public string IsSprinting => isSprinting;
|
||||
public string IsCrouching => isCrouching;
|
||||
public string IsProne => isProne;
|
||||
public string IsSliding => isSliding;
|
||||
public string Stance => stance;
|
||||
public string MovementState => movementState;
|
||||
public string JumpStarted => jumpStarted;
|
||||
public string Landed => landed;
|
||||
public string SlideStarted => slideStarted;
|
||||
public string SlideEnded => slideEnded;
|
||||
public string VaultStarted => vaultStarted;
|
||||
public string VaultEnded => vaultEnded;
|
||||
public string MantleStarted => mantleStarted;
|
||||
public string MantleEnded => mantleEnded;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48eb654a49d14d5998664661cf5b635e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Animation/CharacterAnimatorParameters.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3906dc81be6740418b9d29689f3a89b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,238 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
[RequireComponent(typeof(Camera))]
|
||||
/// <summary>
|
||||
/// A simple follow camera for testing the character controller and running the demo scene.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Deliberately not a gameplay camera framework. Its only contract with the motor is calling
|
||||
/// <see cref="PlayerController.SetMainCameraTransform"/> so movement becomes camera-relative,
|
||||
/// which means any camera — your own, Cinemachine, or an add-on's — can replace it.
|
||||
/// </remarks>
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
[Header("Target")]
|
||||
[SerializeField] private Transform target;
|
||||
[Tooltip("If Target is not assigned, search this component's scene for one PlayerController at startup. Assign Target explicitly for production, split-screen, additive scenes, or multiplayer.")]
|
||||
[SerializeField] private bool autoFindTargetInScene = true;
|
||||
[SerializeField] private Vector3 pivotOffset = new Vector3(0f, 1.4f, 0f);
|
||||
[Tooltip("Lateral camera offset in local space (positive X = over right shoulder).")]
|
||||
[SerializeField] private Vector3 shoulderOffset = new Vector3(0.35f, 0f, 0f);
|
||||
|
||||
[Header("Distance & Follow")]
|
||||
[Tooltip("How far the camera sits behind the pivot, in metres.")]
|
||||
[SerializeField, Min(0.1f)] private float distance = 5f;
|
||||
[Tooltip("How quickly the camera catches up to the target. Higher is tighter.")]
|
||||
[SerializeField, Min(1f)] private float followSpeed = 12f;
|
||||
|
||||
[Header("Look - Mouse")]
|
||||
[Tooltip("Degrees of rotation per unit of mouse delta.")]
|
||||
[SerializeField, Min(0f)] private float mouseSensitivity = 0.15f;
|
||||
[Tooltip("Caps mouse delta per frame so a hitch cannot whip the camera around.")]
|
||||
[SerializeField, Min(0f)] private float maxMouseDeltaPerFrame = 120f;
|
||||
|
||||
[Header("Look - Gamepad")]
|
||||
[Tooltip("Degrees per second at full stick deflection.")]
|
||||
[SerializeField, Min(0f)] private float gamepadSensitivity = 180f;
|
||||
[Tooltip("Stick movement below this is ignored.")]
|
||||
[SerializeField, Range(0f, 0.5f)] private float gamepadDeadzone = 0.15f;
|
||||
|
||||
[Header("Look - Clamp")]
|
||||
[Tooltip("Lowest pitch angle in degrees. Negative looks down at the character.")]
|
||||
[SerializeField] private float minPitch = -20f;
|
||||
[Tooltip("Highest pitch angle in degrees.")]
|
||||
[SerializeField] private float maxPitch = 60f;
|
||||
[Tooltip("Pitch the camera starts at.")]
|
||||
[SerializeField] private float initialPitch = 20f;
|
||||
[Tooltip("Inverts vertical look input.")]
|
||||
[SerializeField] private bool invertY;
|
||||
|
||||
[Header("Collision")]
|
||||
[SerializeField] private bool enableCollision = true;
|
||||
[SerializeField] private LayerMask collisionMask = ~0;
|
||||
[SerializeField, Min(0.05f)] private float collisionRadius = 0.3f;
|
||||
[Tooltip("How fast the camera retracts when blocked (units/sec).")]
|
||||
[SerializeField, Min(1f)] private float retractSpeed = 30f;
|
||||
[Tooltip("How fast the camera extends back out after a block clears (units/sec).")]
|
||||
[SerializeField, Min(0.1f)] private float extendSpeed = 4f;
|
||||
|
||||
[Header("Soft Lock-On")]
|
||||
[SerializeField] private bool enableLockOn = true;
|
||||
[Tooltip("0 = ignore the lock target, 1 = full yaw alignment toward target.")]
|
||||
[SerializeField, Range(0f, 1f)] private float lockOnInfluence = 0.65f;
|
||||
[SerializeField, Min(0.1f)] private float lockOnLerpSpeed = 6f;
|
||||
[Tooltip("Optional pitch bias when locked on (degrees).")]
|
||||
[SerializeField, Range(-30f, 30f)] private float lockOnPitchBias = 8f;
|
||||
|
||||
[Header("Auto Follow")]
|
||||
[Tooltip("Drift camera yaw behind the player when moving and the user is idle on look input.")]
|
||||
[SerializeField, Range(0f, 4f)] private float autoFollowYawSpeed = 1.2f;
|
||||
[Tooltip("Seconds after last look input before auto-follow kicks in.")]
|
||||
[SerializeField, Min(0f)] private float autoFollowIdleTime = 0.6f;
|
||||
|
||||
public Transform LockOnTarget { get; set; }
|
||||
|
||||
private Camera _camera;
|
||||
private float _yaw;
|
||||
private float _pitch;
|
||||
private float _currentDistance;
|
||||
private Vector3 _followVelocity;
|
||||
private float _idleTimer;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!target && autoFindTargetInScene)
|
||||
{
|
||||
PlayerController player = SceneReferenceResolver.FindComponentInSameScene<PlayerController>(this);
|
||||
if (player)
|
||||
target = player.transform;
|
||||
}
|
||||
|
||||
if (target && target.TryGetComponent(out PlayerController controller))
|
||||
controller.SetMainCameraTransform(transform);
|
||||
|
||||
Vector3 euler = transform.eulerAngles;
|
||||
_yaw = euler.y;
|
||||
_pitch = initialPitch;
|
||||
_currentDistance = distance;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
Vector2 lookDelta = ReadLookInput(out bool gamepadActive);
|
||||
ApplyLook(lookDelta, gamepadActive);
|
||||
ApplyAutoFollow(lookDelta.sqrMagnitude);
|
||||
ApplyLockOn();
|
||||
|
||||
Quaternion rotation = Quaternion.Euler(_pitch, _yaw, 0f);
|
||||
Vector3 pivot = target.position + pivotOffset;
|
||||
Vector3 lateral = rotation * shoulderOffset;
|
||||
|
||||
Vector3 cameraDirection = -(rotation * Vector3.forward);
|
||||
float targetDistance = ResolveCollisionDistance(pivot + lateral, cameraDirection);
|
||||
|
||||
if (targetDistance < _currentDistance)
|
||||
_currentDistance = Mathf.MoveTowards(_currentDistance, targetDistance, retractSpeed * Time.deltaTime);
|
||||
else
|
||||
_currentDistance = Mathf.MoveTowards(_currentDistance, targetDistance, extendSpeed * Time.deltaTime);
|
||||
|
||||
Vector3 desiredPosition = pivot + lateral + cameraDirection * _currentDistance;
|
||||
|
||||
Vector3 smoothedPosition = Vector3.SmoothDamp(
|
||||
transform.position,
|
||||
desiredPosition,
|
||||
ref _followVelocity,
|
||||
1f / followSpeed);
|
||||
|
||||
transform.SetPositionAndRotation(smoothedPosition, rotation);
|
||||
}
|
||||
|
||||
private Vector2 ReadLookInput(out bool gamepadActive)
|
||||
{
|
||||
gamepadActive = false;
|
||||
Vector2 result = Vector2.zero;
|
||||
|
||||
Mouse mouse = Mouse.current;
|
||||
if (mouse != null)
|
||||
{
|
||||
Vector2 mouseDelta = mouse.delta.ReadValue();
|
||||
if (maxMouseDeltaPerFrame > 0f)
|
||||
mouseDelta = Vector2.ClampMagnitude(mouseDelta, maxMouseDeltaPerFrame);
|
||||
result = mouseDelta * mouseSensitivity;
|
||||
}
|
||||
|
||||
Gamepad gamepad = Gamepad.current;
|
||||
if (gamepad != null)
|
||||
{
|
||||
Vector2 stick = gamepad.rightStick.ReadValue();
|
||||
if (stick.sqrMagnitude > gamepadDeadzone * gamepadDeadzone)
|
||||
{
|
||||
Vector2 stickDelta = stick * (gamepadSensitivity * Time.deltaTime);
|
||||
if (stickDelta.sqrMagnitude > result.sqrMagnitude)
|
||||
{
|
||||
result = stickDelta;
|
||||
gamepadActive = true;
|
||||
}
|
||||
else if (result.sqrMagnitude < 0.001f)
|
||||
{
|
||||
result = stickDelta;
|
||||
gamepadActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void ApplyLook(Vector2 lookDelta, bool gamepadActive)
|
||||
{
|
||||
float yawDelta = lookDelta.x;
|
||||
float pitchDelta = invertY ? lookDelta.y : -lookDelta.y;
|
||||
|
||||
_yaw += yawDelta;
|
||||
_pitch = Mathf.Clamp(_pitch + pitchDelta, minPitch, maxPitch);
|
||||
|
||||
_idleTimer = lookDelta.sqrMagnitude > 0.0001f ? 0f : _idleTimer + Time.deltaTime;
|
||||
}
|
||||
|
||||
private void ApplyAutoFollow(float lookDeltaSqr)
|
||||
{
|
||||
if (autoFollowYawSpeed <= 0f)
|
||||
return;
|
||||
|
||||
if (_idleTimer < autoFollowIdleTime)
|
||||
return;
|
||||
|
||||
if (!target.TryGetComponent(out PlayerController controller) || controller.RigidBody == null)
|
||||
return;
|
||||
|
||||
Vector3 velocity = controller.RigidBody.linearVelocity;
|
||||
velocity.y = 0f;
|
||||
if (velocity.sqrMagnitude < 0.5f)
|
||||
return;
|
||||
|
||||
float targetYaw = Mathf.Atan2(velocity.x, velocity.z) * Mathf.Rad2Deg;
|
||||
_yaw = Mathf.LerpAngle(_yaw, targetYaw, autoFollowYawSpeed * Time.deltaTime);
|
||||
}
|
||||
|
||||
private void ApplyLockOn()
|
||||
{
|
||||
if (!enableLockOn || lockOnInfluence <= 0f || LockOnTarget == null)
|
||||
return;
|
||||
|
||||
Vector3 toTarget = LockOnTarget.position - (target.position + pivotOffset);
|
||||
toTarget.y = 0f;
|
||||
if (toTarget.sqrMagnitude < 0.0001f)
|
||||
return;
|
||||
|
||||
float yawToTarget = Mathf.Atan2(toTarget.x, toTarget.z) * Mathf.Rad2Deg;
|
||||
float blend = lockOnInfluence * lockOnLerpSpeed * Time.deltaTime;
|
||||
_yaw = Mathf.LerpAngle(_yaw, yawToTarget, blend);
|
||||
|
||||
if (Mathf.Abs(lockOnPitchBias) > 0.01f)
|
||||
_pitch = Mathf.LerpAngle(_pitch, lockOnPitchBias, blend);
|
||||
}
|
||||
|
||||
private float ResolveCollisionDistance(Vector3 castOrigin, Vector3 castDirection)
|
||||
{
|
||||
if (!enableCollision)
|
||||
return distance;
|
||||
|
||||
if (Physics.SphereCast(castOrigin, collisionRadius, castDirection, out RaycastHit hit, distance, collisionMask, QueryTriggerInteraction.Ignore))
|
||||
return Mathf.Max(hit.distance, collisionRadius);
|
||||
|
||||
return distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a01ac3d63e1c814695b6ae5d9680448
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Camera/CameraFollow.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
[AddComponentMenu("Character Controller/Camera/Cinemachine Adapter")]
|
||||
public sealed class CharacterCinemachineAdapter : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[Tooltip("Controller the rig follows. Found automatically when Auto Find Player is on.")]
|
||||
[SerializeField] private PlayerController playerController;
|
||||
[Tooltip("Your Cinemachine camera component. Stored as a plain Component so Core compiles without "
|
||||
+ "Cinemachine installed.")]
|
||||
[SerializeField] private Component cinemachineCamera;
|
||||
[Tooltip("Transform the Cinemachine camera follows.")]
|
||||
[SerializeField] private Transform followTarget;
|
||||
[Tooltip("Transform the Cinemachine camera looks at.")]
|
||||
[SerializeField] private Transform lookAtTarget;
|
||||
|
||||
[Header("Setup")]
|
||||
[Tooltip("Searches this scene for a PlayerController when none is assigned.")]
|
||||
[SerializeField] private bool autoFindPlayer = true;
|
||||
[Tooltip("Searches this GameObject and its children for a Cinemachine camera.")]
|
||||
[SerializeField] private bool autoFindCinemachineCamera = true;
|
||||
[Tooltip("Writes the follow target onto the Cinemachine camera at startup.")]
|
||||
[SerializeField] private bool assignFollowTarget = true;
|
||||
[Tooltip("Writes the look-at target onto the Cinemachine camera at startup.")]
|
||||
[SerializeField] private bool assignLookAtTarget = true;
|
||||
[Tooltip("Tells the controller to treat this camera as the movement reference, so input stays "
|
||||
+ "camera-relative. Keep this on.")]
|
||||
[SerializeField] private bool assignPlayerCameraReference = true;
|
||||
[Tooltip("How often to re-assign the camera reference, in seconds, in case the Cinemachine brain "
|
||||
+ "swaps cameras.")]
|
||||
[SerializeField, Min(0f)] private float cameraReferenceRefreshInterval = 0.25f;
|
||||
|
||||
private Camera _cachedMainCamera;
|
||||
private Transform _lastAssignedCameraTransform;
|
||||
private float _nextCameraReferenceRefreshTime;
|
||||
|
||||
public PlayerController PlayerController => playerController;
|
||||
public Component CinemachineCamera => cinemachineCamera;
|
||||
|
||||
public bool ValidateTargetBindings(out string message)
|
||||
{
|
||||
Component resolvedCamera = cinemachineCamera ? cinemachineCamera : autoFindCinemachineCamera ? FindCinemachineComponent() : null;
|
||||
if (!resolvedCamera)
|
||||
{
|
||||
message = "No Cinemachine camera component is assigned or discoverable on this adapter GameObject.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (assignFollowTarget && !CanSetTransformMember(resolvedCamera, "Follow", "m_Follow"))
|
||||
{
|
||||
message = $"'{resolvedCamera.GetType().Name}' does not expose a writable Follow target member supported by the adapter.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (assignLookAtTarget && !CanSetTransformMember(resolvedCamera, "LookAt", "m_LookAt"))
|
||||
{
|
||||
message = $"'{resolvedCamera.GetType().Name}' does not expose a writable LookAt target member supported by the adapter.";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = "Cinemachine target bindings are supported.";
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
ResolveReferences();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ResolveReferences();
|
||||
ApplyTargets();
|
||||
ApplyPlayerCameraReference();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (cameraReferenceRefreshInterval > 0f
|
||||
&& Time.unscaledTime < _nextCameraReferenceRefreshTime
|
||||
&& _lastAssignedCameraTransform)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyPlayerCameraReference();
|
||||
}
|
||||
|
||||
public bool ApplyTargets()
|
||||
{
|
||||
if (!cinemachineCamera)
|
||||
return false;
|
||||
|
||||
Transform resolvedFollow = followTarget ? followTarget : playerController ? playerController.transform : null;
|
||||
Transform resolvedLookAt = lookAtTarget ? lookAtTarget : resolvedFollow;
|
||||
bool changed = false;
|
||||
|
||||
if (assignFollowTarget && resolvedFollow)
|
||||
changed |= TrySetTransformMember(cinemachineCamera, "Follow", "m_Follow", resolvedFollow);
|
||||
|
||||
if (assignLookAtTarget && resolvedLookAt)
|
||||
changed |= TrySetTransformMember(cinemachineCamera, "LookAt", "m_LookAt", resolvedLookAt);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void ResolveReferences()
|
||||
{
|
||||
if (!playerController && autoFindPlayer)
|
||||
playerController = GetComponentInParent<PlayerController>() ?? SceneReferenceResolver.FindComponentInSameScene<PlayerController>(this);
|
||||
|
||||
if (!followTarget && playerController)
|
||||
followTarget = playerController.transform;
|
||||
|
||||
if (!lookAtTarget)
|
||||
lookAtTarget = followTarget;
|
||||
|
||||
if (!cinemachineCamera && autoFindCinemachineCamera)
|
||||
cinemachineCamera = FindCinemachineComponent();
|
||||
}
|
||||
|
||||
private void ApplyPlayerCameraReference()
|
||||
{
|
||||
if (!assignPlayerCameraReference || !playerController)
|
||||
return;
|
||||
|
||||
_nextCameraReferenceRefreshTime = Time.unscaledTime + cameraReferenceRefreshInterval;
|
||||
Camera mainCamera = ResolveMainCamera();
|
||||
if (!mainCamera)
|
||||
return;
|
||||
|
||||
Transform cameraTransform = mainCamera.transform;
|
||||
if (_lastAssignedCameraTransform == cameraTransform)
|
||||
return;
|
||||
|
||||
playerController.SetMainCameraTransform(cameraTransform);
|
||||
_lastAssignedCameraTransform = cameraTransform;
|
||||
}
|
||||
|
||||
private Camera ResolveMainCamera()
|
||||
{
|
||||
if (_cachedMainCamera)
|
||||
return _cachedMainCamera;
|
||||
|
||||
_cachedMainCamera = SceneReferenceResolver.FindMainCameraInSameScene(this);
|
||||
return _cachedMainCamera;
|
||||
}
|
||||
|
||||
private Component FindCinemachineComponent()
|
||||
{
|
||||
Component[] components = GetComponents<Component>();
|
||||
foreach (Component component in components)
|
||||
{
|
||||
if (component != this && IsCinemachineComponent(component))
|
||||
return component;
|
||||
}
|
||||
|
||||
Component[] children = GetComponentsInChildren<Component>(true);
|
||||
foreach (Component component in children)
|
||||
{
|
||||
if (component != this && IsCinemachineComponent(component))
|
||||
return component;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static bool IsCinemachineComponent(Component component)
|
||||
{
|
||||
if (!component)
|
||||
return false;
|
||||
|
||||
Type type = component.GetType();
|
||||
string fullName = type.FullName ?? string.Empty;
|
||||
return fullName.StartsWith("Cinemachine.", StringComparison.Ordinal)
|
||||
|| type.Name.IndexOf("Cinemachine", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
private static bool TrySetTransformMember(Component component, string propertyName, string fieldName, Transform value)
|
||||
{
|
||||
if (TryGetWritableTransformProperty(component, propertyName, out PropertyInfo property))
|
||||
{
|
||||
if (property.GetValue(component) as Transform == value)
|
||||
return false;
|
||||
|
||||
property.SetValue(component, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TryGetWritableTransformField(component, fieldName, propertyName, out FieldInfo field))
|
||||
{
|
||||
if (field.GetValue(component) as Transform == value)
|
||||
return false;
|
||||
|
||||
field.SetValue(component, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CanSetTransformMember(Component component, string propertyName, string fieldName)
|
||||
{
|
||||
return TryGetWritableTransformProperty(component, propertyName, out _)
|
||||
|| TryGetWritableTransformField(component, fieldName, propertyName, out _);
|
||||
}
|
||||
|
||||
private static bool TryGetWritableTransformProperty(Component component, string propertyName, out PropertyInfo property)
|
||||
{
|
||||
property = null;
|
||||
if (!component)
|
||||
return false;
|
||||
|
||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
property = component.GetType().GetProperty(propertyName, flags);
|
||||
return property != null
|
||||
&& property.CanWrite
|
||||
&& property.PropertyType.IsAssignableFrom(typeof(Transform));
|
||||
}
|
||||
|
||||
private static bool TryGetWritableTransformField(Component component, string fieldName, string fallbackFieldName, out FieldInfo field)
|
||||
{
|
||||
field = null;
|
||||
if (!component)
|
||||
return false;
|
||||
|
||||
const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
||||
Type type = component.GetType();
|
||||
field = type.GetField(fieldName, flags) ?? type.GetField(fallbackFieldName, flags);
|
||||
return field != null
|
||||
&& field.FieldType.IsAssignableFrom(typeof(Transform));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 172c34e7d0ec406fa55c4acd42efde70
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Camera/CharacterCinemachineAdapter.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 103d3495bf4843509d5f5ad87bc3b952
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
/// <summary>
|
||||
/// Toggles the demo HUD and the controller's debug overlay. Demo helper; not part of the
|
||||
/// character motor.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Character Controller/Core/Demo HUD Toggle")]
|
||||
public sealed class DemoHudToggle : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Controller the rig follows. Found automatically when Auto Find Player is on.")]
|
||||
[SerializeField] private PlayerController playerController;
|
||||
[Tooltip("Canvas shown and hidden by the toggle key. Found by name if left empty.")]
|
||||
[SerializeField] private Canvas hudCanvas;
|
||||
[Tooltip("Key that shows and hides the demo HUD and the controller's debug overlay.")]
|
||||
[SerializeField] private KeyCode toggleKey = KeyCode.F1;
|
||||
[Tooltip("Whether the HUD starts visible.")]
|
||||
[SerializeField] private bool visible = true;
|
||||
|
||||
private GUIStyle _hintStyle;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
ResolveReferences();
|
||||
ApplyVisibility();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!InputSystemKeyCodeUtility.WasPressedThisFrame(toggleKey))
|
||||
return;
|
||||
|
||||
visible = !visible;
|
||||
ApplyVisibility();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
EnsureHintStyle();
|
||||
const float width = 210f;
|
||||
const float height = 32f;
|
||||
GUI.Box(
|
||||
new Rect(Screen.width - width - 16f, Screen.height - height - 16f, width, height),
|
||||
"F1 - Hide HUD / debug",
|
||||
_hintStyle);
|
||||
}
|
||||
|
||||
private void ResolveReferences()
|
||||
{
|
||||
if (!playerController)
|
||||
playerController = GetComponent<PlayerController>() ?? SceneReferenceResolver.FindComponentInSameScene<PlayerController>(this);
|
||||
|
||||
if (!hudCanvas)
|
||||
hudCanvas = FindNamedCanvas("HUD_Canvas");
|
||||
}
|
||||
|
||||
private Canvas FindNamedCanvas(string canvasName)
|
||||
{
|
||||
if (!gameObject.scene.IsValid() || !gameObject.scene.isLoaded)
|
||||
return null;
|
||||
|
||||
GameObject[] roots = gameObject.scene.GetRootGameObjects();
|
||||
for (int i = 0; i < roots.Length; i++)
|
||||
{
|
||||
Canvas[] canvases = roots[i].GetComponentsInChildren<Canvas>(true);
|
||||
for (int j = 0; j < canvases.Length; j++)
|
||||
{
|
||||
if (canvases[j] && canvases[j].name == canvasName)
|
||||
return canvases[j];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ApplyVisibility()
|
||||
{
|
||||
if (!playerController || !hudCanvas)
|
||||
ResolveReferences();
|
||||
|
||||
if (playerController)
|
||||
playerController.SetDebugOverlayVisible(visible);
|
||||
|
||||
if (hudCanvas)
|
||||
hudCanvas.enabled = visible;
|
||||
}
|
||||
|
||||
private void EnsureHintStyle()
|
||||
{
|
||||
if (_hintStyle != null)
|
||||
return;
|
||||
|
||||
_hintStyle = new GUIStyle(GUI.skin.box)
|
||||
{
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
fontSize = 13,
|
||||
normal = { textColor = Color.white },
|
||||
padding = new RectOffset(8, 8, 6, 6)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a58c00ec2dc0495e9d82ee1573a5590a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Demo/DemoHudToggle.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace CharacterMovement
|
||||
{
|
||||
/// <summary>
|
||||
/// Ping-pongs a platform between two points. Demo helper used by the generated movement gym;
|
||||
/// it is not part of the character motor.
|
||||
/// </summary>
|
||||
[AddComponentMenu("Character Controller/Core/Demo Moving Platform Mover")]
|
||||
public sealed class DemoMovingPlatformMover : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Offset from the starting position the platform travels to, in local space.")]
|
||||
[SerializeField] private Vector3 localOffset = new Vector3(0f, 0f, 3f);
|
||||
[Tooltip("Seconds for one leg of the round trip.")]
|
||||
[SerializeField, Min(0.1f)] private float duration = 2.5f;
|
||||
|
||||
private Vector3 _startPosition;
|
||||
private Rigidbody _rigidbody;
|
||||
|
||||
public Vector3 LocalOffset
|
||||
{
|
||||
get => localOffset;
|
||||
set => localOffset = value;
|
||||
}
|
||||
|
||||
public float Duration
|
||||
{
|
||||
get => duration;
|
||||
set => duration = Mathf.Max(0.1f, value);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_startPosition = transform.position;
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
float phase = Mathf.PingPong(Time.time / duration, 1f);
|
||||
Vector3 target = _startPosition + transform.TransformDirection(localOffset) * phase;
|
||||
|
||||
if (_rigidbody && _rigidbody.isKinematic)
|
||||
_rigidbody.MovePosition(target);
|
||||
else
|
||||
transform.position = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b453ced1145f4db9b69f47cb743de015
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 367142
|
||||
packageName: "MotionCore \u2013 Physics Character Controller"
|
||||
packageVersion: 1.2
|
||||
assetPath: Assets/Character Controller/Core/Scripts/Demo/DemoMovingPlatformMover.cs
|
||||
uploadId: 997018
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e5ae8265c374254f975ada5d9a3b321
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loaded 100 of 875 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user