From 65ed53a40f990e895305ff17a5e48e3cd6b8785b Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 24 Oct 2020 17:30:07 +0800 Subject: =?UTF-8?q?*=E7=89=A9=E7=90=86=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Physics/PhysicsPrimitive.cs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'Assets/Scripts/Physics/PhysicsPrimitive.cs') diff --git a/Assets/Scripts/Physics/PhysicsPrimitive.cs b/Assets/Scripts/Physics/PhysicsPrimitive.cs index 59c56aaf..f52fb9e9 100644 --- a/Assets/Scripts/Physics/PhysicsPrimitive.cs +++ b/Assets/Scripts/Physics/PhysicsPrimitive.cs @@ -30,15 +30,15 @@ public abstract class PhysicsPrimitive : MonoBehaviour { get { - return transform.TransformPoint(m_Center); + Vector3 euler = Quaternion.ToEulerAngles(transform.rotation); + euler.y = Mathf.Rad2Deg * euler.y; + Vector3 res = m_Center; + res.x = (euler.y > 90 && euler.y <= 180) ? -res.x : res.x; + res = transform.position + res; + return res; } } - /// - /// 中心点在本地空间的位置 - /// - public Vector3 m_Center; - [SerializeField] /// /// 这个primitive是否参与物理计算,用来快速给物体取消和恢复重力影响 @@ -124,6 +124,7 @@ public abstract class PhysicsPrimitive : MonoBehaviour protected void OnInit() { m_ID = UIDManager.Acquire(); + PhysicsWorld.Instance.AddPrimitive(this); } protected Color Color_Green = new Color(0,1, 0, 0.5f); @@ -133,6 +134,19 @@ public abstract class PhysicsPrimitive : MonoBehaviour [Tooltip("Physics body, leave blank and primitive will be static.")] [SerializeField] - protected PhysicsBody m_Body; + protected PhysicsBody m_Body; + + public PhysicsBody Body + { + get + { + return m_Body; + } + } + + /// + /// 中心点在本地空间的位置 + /// + public Vector3 m_Center; } \ No newline at end of file -- cgit v1.1-26-g67d0