void Start() { // コリジョンの呼び出し this.col = this.GetComponentInChildren <CollisionPart>(true); this.col.Initialize(COL_CATEGORY.PLAYER, HitCallback); this.col.WakeUp(); }
private static void DrawWireGizmo(Transform trans, GizmoType gizmoType) { CollisionPart t = trans.GetComponent <CollisionPart>(); if (t == null) { return; } SerializedObject so = new SerializedObject(t); SerializedProperty arrayProp = so.FindProperty("collisionDatas"); SerializedProperty dataProp = null; SerializedProperty prop = null; for (int i = 0; i < arrayProp.arraySize; ++i) { Gizmos.color = new Color(0f, 1f, 0f, 1f); dataProp = arrayProp.GetArrayElementAtIndex(i); prop = dataProp.FindPropertyRelative("offset"); Vector3 offset = prop.vector3Value; prop = dataProp.FindPropertyRelative("range"); float range = prop.floatValue; Quaternion rotation = trans.rotation; Vector3 position = trans.position + rotation * offset; Vector3 scale = new Vector3(1f, 1f, 0.01f); Gizmos.matrix = Matrix4x4.TRS(position, rotation, scale); Gizmos.DrawWireSphere(Vector3.zero, range); Gizmos.matrix = Matrix4x4.identity; Gizmos.color = Color.white; } }
public void AddPart(uint meshId, Matrix4 localTransform, object tag, int suridx = 0) { var sur = surs[suridx]; if (!sur.HasShape(meshId)) { return; } var hulls = sur.GetShape(meshId); var pt = new CollisionPart() { Tag = tag, Index = currentIndex, Count = hulls.Length }; var tr = localTransform.Cast(); foreach (var h in hulls) { btCompound.AddChildShape(tr, h); } currentIndex += hulls.Length; }
private static void DrawWireGizmo(Transform transform, GizmoType gizmoType) { CollisionPart t = transform.GetComponent <CollisionPart>(); if (t == null) { return; } SerializedObject so = new SerializedObject(t); SerializedProperty dataArrayProp = so.FindProperty("collisionDatas"); for (int i = 0; i < dataArrayProp.arraySize; ++i) { Gizmos.color = new Color(0f, 1f, 0f, 1f); SerializedProperty dataProp = dataArrayProp.GetArrayElementAtIndex(i); float range = dataProp.FindPropertyRelative("range").floatValue; int form = dataProp.FindPropertyRelative("form").enumValueIndex; Vector2 size = dataProp.FindPropertyRelative("size").vector2Value; Vector3 offset = dataProp.FindPropertyRelative("offset").vector3Value; float angle = dataProp.FindPropertyRelative("angle").floatValue; Quaternion rotation = t.transform.rotation; Vector3 position = t.transform.position + rotation * offset; Gizmos.matrix = Matrix4x4.TRS(position, Quaternion.AngleAxis(t.transform.eulerAngles.z + angle, Vector3.forward), new Vector3(1f, 1f, 0.01f)); if (form == (int)COL_FORM.CIRCLE) { Gizmos.DrawWireSphere(Vector3.zero, range); } else { Vector3 cubeSize = new Vector3(size.x, size.y); Gizmos.DrawWireCube(Vector3.zero, cubeSize); } Gizmos.matrix = Matrix4x4.identity; Gizmos.color = Color.white; } }