From ad13abebea1ded24f2450e287663aa4ccd88c33f Mon Sep 17 00:00:00 2001 From: MuhamadAjiW <16521119@mahasiswa.itb.ac.id> Date: Fri, 26 Apr 2024 22:47:02 +0700 Subject: [PATCH] fix: ground detection --- .../Weapons/TestWeapon/TestWeaponModel.prefab | 6 ++-- .../Weapons/TestWeapon/TestWeapon.prefab | 32 ++----------------- Assets/Scenes/DevRoom.unity | 19 +++++++---- .../BaseClasses/EntityObject/WorldEntity.cs | 2 +- Assets/_Scripts/Library/BaseClasses/Model.cs | 5 ++- 5 files changed, 21 insertions(+), 43 deletions(-) diff --git a/Assets/Resources/Models/Weapons/TestWeapon/TestWeaponModel.prefab b/Assets/Resources/Models/Weapons/TestWeapon/TestWeaponModel.prefab index 8b0b181a..9887ece4 100644 --- a/Assets/Resources/Models/Weapons/TestWeapon/TestWeaponModel.prefab +++ b/Assets/Resources/Models/Weapons/TestWeapon/TestWeaponModel.prefab @@ -29,7 +29,7 @@ Transform: m_GameObject: {fileID: 6146631199650576833} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0.3} m_LocalScale: {x: 0.1, y: 0.1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -121,4 +121,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3} m_Name: m_EditorClassIdentifier: - WeaponPivot: {x: 0, y: 0, z: 0} + staticWeaponPivot: {x: 0, y: 0, z: 0} + dynamicBottomPoint: {fileID: 0} + dynamicWeaponPivot: {fileID: 0} diff --git a/Assets/Resources/Prefabs/Weapons/TestWeapon/TestWeapon.prefab b/Assets/Resources/Prefabs/Weapons/TestWeapon/TestWeapon.prefab index 31422c4b..5a898376 100644 --- a/Assets/Resources/Prefabs/Weapons/TestWeapon/TestWeapon.prefab +++ b/Assets/Resources/Prefabs/Weapons/TestWeapon/TestWeapon.prefab @@ -16,7 +16,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1050311400148833009 Transform: m_ObjectHideFlags: 0 @@ -26,7 +26,7 @@ Transform: m_GameObject: {fileID: 5240801910879785525} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.258, y: 0.889, z: 0.375} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -57,34 +57,6 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 1050311400148833009} m_Modifications: - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - target: {fileID: 691014024523472006, guid: 50599534a77c7dd46b591a71fbb5feba, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 diff --git a/Assets/Scenes/DevRoom.unity b/Assets/Scenes/DevRoom.unity index e9d64558..dd12ef15 100644 --- a/Assets/Scenes/DevRoom.unity +++ b/Assets/Scenes/DevRoom.unity @@ -301,7 +301,7 @@ Transform: m_GameObject: {fileID: 464623400} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 2.08, y: 1, z: 3.57} + m_LocalPosition: {x: 2.08, y: 2, z: 3.57} m_LocalScale: {x: 1, y: 4, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -711,7 +711,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalPosition.y - value: 0.15 + value: 1.03 objectReference: {fileID: 0} - target: {fileID: 5801067718172810331, guid: c21e0108f08f0d74b92e3576ec7a7ecc, type: 3} propertyPath: m_LocalPosition.z @@ -813,7 +813,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalPosition.y - value: 0 + value: 1 objectReference: {fileID: 0} - target: {fileID: 6141342063799955615, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} propertyPath: m_LocalPosition.z @@ -851,6 +851,10 @@ PrefabInstance: propertyPath: m_Name value: Dummy objectReference: {fileID: 0} + - target: {fileID: 8491347043216026353, guid: 7e312250336c0244193b4b75151d4fe3, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -874,7 +878,7 @@ PrefabInstance: objectReference: {fileID: 13400000, guid: 6b36fb2e3a8a80643988a623d515cbcc, type: 2} - target: {fileID: 5263704032773805873, guid: c98b222ded23bb24690e674886e5741a, type: 3} propertyPath: m_LocalPosition.y - value: -0.17 + value: 0 objectReference: {fileID: 0} - target: {fileID: 6541102688641435260, guid: c98b222ded23bb24690e674886e5741a, type: 3} propertyPath: m_Name @@ -886,7 +890,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} propertyPath: m_LocalPosition.y - value: 0 + value: 0.5 objectReference: {fileID: 0} - target: {fileID: 7065619579114910469, guid: c98b222ded23bb24690e674886e5741a, type: 3} propertyPath: m_LocalPosition.z @@ -1049,7 +1053,7 @@ Transform: m_GameObject: {fileID: 1819086314} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -0.875, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 100, y: 0.25, z: 100} m_ConstrainProportionsScale: 0 m_Children: @@ -16035,7 +16039,7 @@ Transform: m_GameObject: {fileID: 6980932137625789381} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 1.117, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -16637,6 +16641,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: staticWeaponPivot: {x: 0, y: 0, z: 0} + dynamicBottomPoint: {fileID: 4405864418124909757} dynamicWeaponPivot: {fileID: 3706625295582542003} --- !u!1 &7805749297904559699 GameObject: diff --git a/Assets/_Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs b/Assets/_Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs index 72995497..2245c671 100644 --- a/Assets/_Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs +++ b/Assets/_Scripts/Library/BaseClasses/EntityObject/WorldEntity.cs @@ -50,7 +50,7 @@ public class WorldEntity : WorldObject, IRigid } #endif - groundDetectionSize = new Vector3(0.05f, 0.02f, 0.05f); + groundDetectionSize = new Vector3(0.05f, 0.05f, 0.05f); groundLayers = LayerMask.GetMask(EnvironmentConfig.LAYER_DEFAULT); model.gameObject.layer = LayerMask.NameToLayer(LayerCode); } diff --git a/Assets/_Scripts/Library/BaseClasses/Model.cs b/Assets/_Scripts/Library/BaseClasses/Model.cs index 83f40687..1e210477 100644 --- a/Assets/_Scripts/Library/BaseClasses/Model.cs +++ b/Assets/_Scripts/Library/BaseClasses/Model.cs @@ -5,20 +5,19 @@ public class Model : MonoBehaviour { // Attributes public Vector3 staticWeaponPivot; + public Transform dynamicBottomPoint; public Transform dynamicWeaponPivot; [NonSerialized] public new Renderer renderer; [NonSerialized] public float bottomOffset; // Set-getters public Vector3 WeaponPivot => dynamicWeaponPivot == null ? staticWeaponPivot : dynamicWeaponPivot.position; - public Vector3 Bottom => new(transform.position.x, transform.position.y - bottomOffset, transform.position.z); + public Vector3 Bottom => dynamicBottomPoint == null? new(transform.position.x, transform.position.y - bottomOffset, transform.position.z) : dynamicBottomPoint.position; // Constructors protected void Start(){ renderer = GetComponent<Renderer>(); - Debug.Log(renderer); - #if STRICT if (renderer == null) { -- GitLab