Skip to content

Commit 4ec8e2b

Browse files
committed
Added character controller radius as a debug value
1 parent 783d225 commit 4ec8e2b

File tree

7 files changed

+132
-3
lines changed

7 files changed

+132
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:7f5a90727c0e14591691884e7260bf1ccf871fc67347d6f3eb1fe99effb959dd
3+
size 305768

unity-renderer/Assets/Scripts/MainScripts/DCL/Components/Avatar/Animations/Addressables/gltf/Hit_Wall_Walk1.glb.meta

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterControllerV2/Animation/CharacterAnimator.controller

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ AnimatorStateMachine:
209209
- serializedVersion: 1
210210
m_State: {fileID: 6383020052979447455}
211211
m_Position: {x: 320, y: 200, z: 0}
212+
- serializedVersion: 1
213+
m_State: {fileID: 6626008193833255465}
214+
m_Position: {x: 70, y: 200, z: 0}
212215
m_ChildStateMachines:
213216
- serializedVersion: 1
214217
m_StateMachine: {fileID: -2772301717899763986}
@@ -567,6 +570,7 @@ AnimatorState:
567570
- {fileID: 6523002794003186921}
568571
- {fileID: 4615173915622944316}
569572
- {fileID: 4302603106001568696}
573+
- {fileID: -2920629328503316622}
570574
m_StateMachineBehaviours: []
571575
m_Position: {x: 50, y: 50, z: 0}
572576
m_IKOnFeet: 0
@@ -596,6 +600,28 @@ AnimatorTransition:
596600
m_Mute: 0
597601
m_IsExit: 0
598602
serializedVersion: 1
603+
--- !u!1101 &-3254845168138664480
604+
AnimatorStateTransition:
605+
m_ObjectHideFlags: 1
606+
m_CorrespondingSourceObject: {fileID: 0}
607+
m_PrefabInstance: {fileID: 0}
608+
m_PrefabAsset: {fileID: 0}
609+
m_Name:
610+
m_Conditions: []
611+
m_DstStateMachine: {fileID: 0}
612+
m_DstState: {fileID: -4050450968213979288}
613+
m_Solo: 0
614+
m_Mute: 0
615+
m_IsExit: 0
616+
serializedVersion: 3
617+
m_TransitionDuration: 0.1
618+
m_TransitionOffset: 0
619+
m_ExitTime: 0.9
620+
m_HasExitTime: 1
621+
m_HasFixedDuration: 0
622+
m_InterruptionSource: 0
623+
m_OrderedInterruption: 1
624+
m_CanTransitionToSelf: 1
599625
--- !u!1102 &-3189615017533020249
600626
AnimatorState:
601627
serializedVersion: 6
@@ -625,6 +651,31 @@ AnimatorState:
625651
m_MirrorParameter:
626652
m_CycleOffsetParameter:
627653
m_TimeParameter:
654+
--- !u!1101 &-2920629328503316622
655+
AnimatorStateTransition:
656+
m_ObjectHideFlags: 1
657+
m_CorrespondingSourceObject: {fileID: 0}
658+
m_PrefabInstance: {fileID: 0}
659+
m_PrefabAsset: {fileID: 0}
660+
m_Name:
661+
m_Conditions:
662+
- m_ConditionMode: 1
663+
m_ConditionEvent: WallHit
664+
m_EventTreshold: 0
665+
m_DstStateMachine: {fileID: 0}
666+
m_DstState: {fileID: 6626008193833255465}
667+
m_Solo: 0
668+
m_Mute: 0
669+
m_IsExit: 0
670+
serializedVersion: 3
671+
m_TransitionDuration: 0.1
672+
m_TransitionOffset: 0
673+
m_ExitTime: 0.7619048
674+
m_HasExitTime: 0
675+
m_HasFixedDuration: 0
676+
m_InterruptionSource: 0
677+
m_OrderedInterruption: 1
678+
m_CanTransitionToSelf: 1
628679
--- !u!1107 &-2772301717899763986
629680
AnimatorStateMachine:
630681
serializedVersion: 6
@@ -1020,6 +1071,12 @@ AnimatorController:
10201071
m_DefaultInt: 0
10211072
m_DefaultBool: 0
10221073
m_Controller: {fileID: 9100000}
1074+
- m_Name: WallHit
1075+
m_Type: 9
1076+
m_DefaultFloat: 0
1077+
m_DefaultInt: 0
1078+
m_DefaultBool: 0
1079+
m_Controller: {fileID: 9100000}
10231080
m_AnimatorLayers:
10241081
- serializedVersion: 5
10251082
m_Name: Base Layer
@@ -1837,6 +1894,34 @@ AnimatorStateTransition:
18371894
m_InterruptionSource: 0
18381895
m_OrderedInterruption: 1
18391896
m_CanTransitionToSelf: 1
1897+
--- !u!1102 &6626008193833255465
1898+
AnimatorState:
1899+
serializedVersion: 6
1900+
m_ObjectHideFlags: 1
1901+
m_CorrespondingSourceObject: {fileID: 0}
1902+
m_PrefabInstance: {fileID: 0}
1903+
m_PrefabAsset: {fileID: 0}
1904+
m_Name: Hit_Wall_Walk
1905+
m_Speed: 1
1906+
m_CycleOffset: 0
1907+
m_Transitions:
1908+
- {fileID: -3254845168138664480}
1909+
m_StateMachineBehaviours: []
1910+
m_Position: {x: 50, y: 50, z: 0}
1911+
m_IKOnFeet: 0
1912+
m_WriteDefaultValues: 1
1913+
m_Mirror: 0
1914+
m_SpeedParameterActive: 0
1915+
m_MirrorParameterActive: 0
1916+
m_CycleOffsetParameterActive: 0
1917+
m_TimeParameterActive: 0
1918+
m_Motion: {fileID: -6672892254597440664, guid: c755ae80c4b0ab94790b66e065c4c74d,
1919+
type: 3}
1920+
m_Tag:
1921+
m_SpeedParameter:
1922+
m_MirrorParameter:
1923+
m_CycleOffsetParameter:
1924+
m_TimeParameter:
18401925
--- !u!1101 &6813915900561617564
18411926
AnimatorStateTransition:
18421927
m_ObjectHideFlags: 1

unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterControllerV2/CharacterControllerData.asset

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ MonoBehaviour:
7676
maxAcceleration: 25
7777
accelerationTime: 0.5
7878
longFallStunTime: 0.75
79-
noSlipDistance: 0.1
79+
noSlipDistance: 0.15
8080
slipSpeedMultiplier: 7
8181
jumpHeightStun: 10
8282
jumpVelocityDrag: 5
8383
movAnimBlendSpeed: 5
84+
characterControllerRadius: 0.4

unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterControllerV2/CharacterControllerData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using UnityEngine;
2+
using UnityEngine.Serialization;
23

34
namespace MainScripts.DCL.Controllers.CharacterControllerV2
45
{
@@ -33,5 +34,6 @@ public class CharacterControllerData : ScriptableObject
3334
public float jumpHeightStun = 10f;
3435
public float jumpVelocityDrag = 3f;
3536
public float movAnimBlendSpeed = 3f;
37+
[FormerlySerializedAs("characterControllerWidth")] public float characterControllerRadius = 0.5f;
3638
}
3739
}

unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterControllerV2/CharacterView.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ private void Update()
156156
if (Input.GetKeyDown(KeyCode.N))
157157
showDebug = !showDebug;
158158

159+
characterController.radius = data.characterControllerRadius;
160+
characterController.skinWidth = characterController.radius * 0.1f; // its recommended that its 10% of the radius
159161
controller.Update(Time.deltaTime);
160162

161163
var tpsCamera = DataStore.i.camera.tpsCamera.Get();
@@ -246,6 +248,7 @@ private void OnGUI()
246248
data.slipSpeedMultiplier = DrawFloatField(firstColumnPosition, ref firstColumnYPos, data.slipSpeedMultiplier, "slipSpeedMultiplier");
247249
data.jumpVelocityDrag = DrawFloatField(firstColumnPosition, ref firstColumnYPos, data.jumpVelocityDrag, "jumpVelocityDrag");
248250
data.movAnimBlendSpeed = DrawFloatField(firstColumnPosition, ref firstColumnYPos, data.movAnimBlendSpeed, "movAnimBlendSpeed");
251+
data.characterControllerRadius = DrawFloatField(firstColumnPosition, ref firstColumnYPos, data.characterControllerRadius, "characterRadius");
249252

250253
var secondColumnYPos = 0;
251254
DrawObjectValue(secondColumnPosition, ref secondColumnYPos, "State", characterState.SpeedState);

unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/CharacterControllerV2/DCLCharacterControllerV2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void UpdateShadowBlob()
234234
shadowBlob.SetActive(true);
235235
groundRay.origin = view.GetPosition();
236236

237-
if (Physics.Raycast(groundRay, out var hit, 50f, groundLayers))
237+
if (Physics.SphereCast(groundRay, data.characterControllerRadius , out var hit, 50f, groundLayers))
238238
{
239239
shadowBlob.transform.position = hit.point;
240240
shadowBlob.transform.up = hit.normal;
@@ -299,7 +299,7 @@ private Vector3 GetSlopeModifier()
299299

300300
// spherecast downwards to check slopes
301301
if (!Physics.SphereCast(currentPosition,
302-
settings.radius, Vector3.down, out sphereCastHitInfo,
302+
data.characterControllerRadius, Vector3.down, out sphereCastHitInfo,
303303
1, groundLayers)) return Vector3.zero;
304304

305305
Vector3 relativeHitPoint = sphereCastHitInfo.point - (currentPosition + settings.center);

0 commit comments

Comments
 (0)