Skip to content
Snippets Groups Projects
Commit bb55926b authored by MuhamadAjiW's avatar MuhamadAjiW
Browse files

mod: removed convention of rigid body at bottom of model

parent 19e6360e
1 merge request!2Base arch
...@@ -143,4 +143,6 @@ MonoBehaviour: ...@@ -143,4 +143,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3} m_Script: {fileID: 11500000, guid: dc4d5359067cdfb47a45684d6cc1482a, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
WeaponPivot: {x: 0.258, y: 0.75, z: 0.375} staticWeaponPivot: {x: 0.2, y: 0, z: 0.375}
renderer: {fileID: 0}
bottomOffset: 0
...@@ -84,8 +84,7 @@ public class WorldEntity : WorldObject, IRigid ...@@ -84,8 +84,7 @@ public class WorldEntity : WorldObject, IRigid
return; return;
} }
Vector3 center = transform.position; Collider[] groundOverlaps = Physics.OverlapBox(model.Bottom, groundDetectionSize, Quaternion.identity, groundLayers);
Collider[] groundOverlaps = Physics.OverlapBox(center, groundDetectionSize, Quaternion.identity, groundLayers);
grounded = groundOverlaps.Length != 0; grounded = groundOverlaps.Length != 0;
} }
} }
\ No newline at end of file
...@@ -3,5 +3,24 @@ using UnityEngine; ...@@ -3,5 +3,24 @@ using UnityEngine;
public class Model : MonoBehaviour public class Model : MonoBehaviour
{ {
// Attributes // Attributes
public Vector3 WeaponPivot; public Vector3 staticWeaponPivot;
} public new Renderer renderer;
\ No newline at end of file public float bottomOffset;
// Set-getters
public Vector3 WeaponPivot => staticWeaponPivot;
public Vector3 Bottom => new(transform.position.x, transform.position.y - bottomOffset, transform.position.z);
// Constructors
protected void Start(){
Renderer renderer = GetComponent<Renderer>();
#if STRICT
if(renderer == null)
{
Debug.LogError($"Did you seriously just create a model {name} without a renderer? How to resolve: Add a renderer (meshrenderer or skinnedmeshrenderer) to the model");
}
#endif
bottomOffset = renderer.bounds.extents.y;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment