37 lines
980 B
C#
Raw Normal View History

2024-01-31 19:16:05 +08:00
using BepuPhysics;
using BepuPhysics.Collidables;
using UnityEngine;
using NotImplementedException = System.NotImplementedException;
using Quaternion = System.Numerics.Quaternion;
using Vector3 = System.Numerics.Vector3;
namespace Plugins.JNGame.BepuPhysics.Components
{
public class BPhysicsBox : BPhysicsBase
{
private BodyHandle bodyId;
void Awake()
{
if (this.Physics == null) return;
Debug.Log("BPhysicsSphere");
this.Physics.Shapes.Add(this);
var localScale = transform.localScale;
var sphereBox = new Box(localScale.x,localScale.y,localScale.z);
if (this.isStatic)
{
this.AddStatic(sphereBox);
}
else
{
sphereBox.ComputeInertia(0.5f, out var inertia);
this.AddDynamic(sphereBox,inertia);
}
}
}
}