mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-14 17:09:31 +07:00
physics wip
This commit is contained in:
@@ -87,6 +87,100 @@ NavMeshSettings:
|
||||
cellSize: .166666672
|
||||
manualCellSize: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1001 &194071307
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: _position.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: _position.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &194071308 stripped
|
||||
GameObject:
|
||||
m_PrefabParentObject: {fileID: 153404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
m_PrefabInternal: {fileID: 194071307}
|
||||
--- !u!114 &194071309
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 194071308}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_isKinematic: 1
|
||||
_interpolation: 0
|
||||
_collisionDetectionMode: 0
|
||||
--- !u!114 &194071310
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 194071308}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b256250c588ee4e4590a3e58eaa69b1d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_material: {fileID: 0}
|
||||
_isTrigger: 0
|
||||
_size: {x: 3, y: 3, z: 0}
|
||||
_offset: {x: 1.5, y: 1.5, z: 0}
|
||||
--- !u!114 &194071311
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 194071308}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5528e050e2d53409f9a4f1662625b0bf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &318480492
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -187,161 +281,84 @@ MonoBehaviour:
|
||||
_tileSize: 16
|
||||
_minDepth: 0
|
||||
_maxDepth: 100
|
||||
--- !u!1001 &562183236
|
||||
--- !u!1001 &1846453512
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 64
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
propertyPath: _position.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11453404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.x
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.z
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &562183237 stripped
|
||||
--- !u!1 &1846453513 stripped
|
||||
GameObject:
|
||||
m_PrefabParentObject: {fileID: 153404, guid: d10e5320df9f84d4186bda0ba98db9ff, type: 2}
|
||||
m_PrefabInternal: {fileID: 562183236}
|
||||
--- !u!114 &562183238
|
||||
m_PrefabParentObject: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
m_PrefabInternal: {fileID: 1846453512}
|
||||
--- !u!114 &1846453514
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 562183237}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b256250c588ee4e4590a3e58eaa69b1d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_material: {fileID: 0}
|
||||
_isTrigger: 0
|
||||
_size: {x: 3, y: 3, z: 0}
|
||||
_offset: {x: 1.5, y: 1.5, z: 0}
|
||||
--- !u!114 &562183239
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 562183237}
|
||||
m_GameObject: {fileID: 1846453513}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_isKinematic: 1
|
||||
_isKinematic: 0
|
||||
_interpolation: 0
|
||||
_collisionDetectionMode: 0
|
||||
--- !u!1001 &844501808
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -3.59999847
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 75.8300018
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.x
|
||||
value: .626875162
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.y
|
||||
value: .851875067
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _position.z
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _alignment
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 11417528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
propertyPath: _showBounds
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
--- !u!1 &844501809 stripped
|
||||
GameObject:
|
||||
m_PrefabParentObject: {fileID: 117528, guid: c1b9b2ad3a021c549aa9190df3101248, type: 2}
|
||||
m_PrefabInternal: {fileID: 844501808}
|
||||
--- !u!114 &844501810
|
||||
--- !u!114 &1846453515
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 844501809}
|
||||
m_GameObject: {fileID: 1846453513}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b256250c588ee4e4590a3e58eaa69b1d, type: 3}
|
||||
@@ -351,17 +368,3 @@ MonoBehaviour:
|
||||
_isTrigger: 0
|
||||
_size: {x: 1, y: 1, z: 1}
|
||||
_offset: {x: .5, y: .5, z: .5}
|
||||
--- !u!114 &844501811
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 844501809}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4febe544112bb4678bdd59fa963c802d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_isKinematic: 0
|
||||
_interpolation: 0
|
||||
_collisionDetectionMode: 0
|
||||
|
||||
30
Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs
Normal file
30
Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace IsoTools { namespace Examples {
|
||||
public class IsoEchoListener : MonoBehaviour {
|
||||
void OnIsoTriggerEnter(IsoCollider iso_collider) {
|
||||
Debug.LogFormat(
|
||||
"OnIsoTriggerEnter. self:{0} other:{1}",
|
||||
gameObject.name, iso_collider.gameObject.name);
|
||||
}
|
||||
|
||||
void OnIsoTriggerExit(IsoCollider iso_collider) {
|
||||
Debug.LogFormat(
|
||||
"OnIsoTriggerExit. self:{0} other:{1}",
|
||||
gameObject.name, iso_collider.gameObject.name);
|
||||
}
|
||||
|
||||
void OnIsoCollisionEnter(IsoCollision iso_collision) {
|
||||
Debug.LogFormat(
|
||||
"OnIsoCollisionEnter. self:{0} other:{1}",
|
||||
gameObject.name, iso_collision.GameObject.name);
|
||||
}
|
||||
|
||||
void OnIsoCollisionExit(IsoCollision iso_collision) {
|
||||
Debug.LogFormat(
|
||||
"OnIsoCollisionExit. self:{0} other:{1}",
|
||||
gameObject.name, iso_collision.GameObject.name);
|
||||
}
|
||||
}
|
||||
}} // namespace IsoTools::Examples
|
||||
12
Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs.meta
Normal file
12
Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5528e050e2d53409f9a4f1662625b0bf
|
||||
timeCreated: 1436185285
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -33,18 +33,23 @@ namespace IsoTools {
|
||||
}
|
||||
}
|
||||
|
||||
Collider _realCollider = null;
|
||||
GameObject _isoFakeCollider = null;
|
||||
public GameObject IsoFakeCollider {
|
||||
get { return _isoFakeCollider; }
|
||||
}
|
||||
|
||||
public Collider RealCollider {
|
||||
get { return _realCollider; }
|
||||
get { return IsoFakeCollider ? IsoFakeCollider.GetComponent<Collider>() : null; }
|
||||
}
|
||||
|
||||
void Awake() {
|
||||
var helper = IsoUtils.GetOrCreateComponent<IsoPhysicHelper>(gameObject);
|
||||
_realCollider = CreateCollider(helper.IsoFakeObject);
|
||||
if ( _realCollider ) {
|
||||
_realCollider.material = Material;
|
||||
_realCollider.isTrigger = IsTrigger;
|
||||
}
|
||||
_isoFakeCollider = new GameObject();
|
||||
_isoFakeCollider.transform.SetParent(
|
||||
IsoUtils.GetOrCreateComponent<IsoPhysicHelper>(gameObject).IsoFakeObject.transform, false);
|
||||
_isoFakeCollider.AddComponent<IsoFakeCollider>().Init(this);
|
||||
var real_collider = CreateCollider(_isoFakeCollider);
|
||||
real_collider.material = Material;
|
||||
real_collider.isTrigger = IsTrigger;
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
@@ -60,9 +65,9 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
if ( _realCollider ) {
|
||||
Destroy(_realCollider);
|
||||
_realCollider = null;
|
||||
if ( _isoFakeCollider ) {
|
||||
Destroy(_isoFakeCollider);
|
||||
_isoFakeCollider = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
Assets/IsoTools/Scripts/IsoCollision.cs
Normal file
26
Assets/IsoTools/Scripts/IsoCollision.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IsoTools {
|
||||
public class IsoCollision {
|
||||
|
||||
public IsoCollider Collider { get; private set; }
|
||||
public IsoContactPoint[] Contacts { get; private set; }
|
||||
public GameObject GameObject { get; private set; }
|
||||
public Vector3 RelativeVelocity { get; private set; }
|
||||
public IsoRigidbody IsoRigidbody { get; private set; }
|
||||
|
||||
public IsoCollision(
|
||||
IsoCollider collider,
|
||||
IsoContactPoint[] contacts,
|
||||
GameObject game_object,
|
||||
Vector3 relative_velocity,
|
||||
IsoRigidbody iso_rigidbody)
|
||||
{
|
||||
Collider = collider;
|
||||
Contacts = contacts;
|
||||
GameObject = game_object;
|
||||
RelativeVelocity = relative_velocity;
|
||||
IsoRigidbody = iso_rigidbody;
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools
|
||||
12
Assets/IsoTools/Scripts/IsoCollision.cs.meta
Normal file
12
Assets/IsoTools/Scripts/IsoCollision.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a0c6ad7ad6d84258be23c24fad58b84
|
||||
timeCreated: 1436119603
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/IsoTools/Scripts/IsoContactPoint.cs
Normal file
23
Assets/IsoTools/Scripts/IsoContactPoint.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IsoTools {
|
||||
public class IsoContactPoint {
|
||||
|
||||
public Vector3 Normal { get; private set; }
|
||||
public IsoCollider OtherIsoCollider { get; private set; }
|
||||
public Vector3 Point { get; private set; }
|
||||
public IsoCollider ThisIsoCollider { get; private set; }
|
||||
|
||||
public IsoContactPoint(
|
||||
Vector3 normal,
|
||||
IsoCollider other_iso_collider,
|
||||
Vector3 point,
|
||||
IsoCollider this_iso_collider)
|
||||
{
|
||||
Normal = normal;
|
||||
OtherIsoCollider = other_iso_collider;
|
||||
Point = point;
|
||||
ThisIsoCollider = this_iso_collider;
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools
|
||||
12
Assets/IsoTools/Scripts/IsoContactPoint.cs.meta
Normal file
12
Assets/IsoTools/Scripts/IsoContactPoint.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 121a2248ec18d4aa4be6bec03265e86e
|
||||
timeCreated: 1436119761
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/IsoTools/Scripts/IsoFakeCollider.cs
Normal file
16
Assets/IsoTools/Scripts/IsoFakeCollider.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IsoTools {
|
||||
public class IsoFakeCollider : MonoBehaviour {
|
||||
|
||||
IsoCollider _isoCollider = null;
|
||||
|
||||
public void Init(IsoCollider iso_collider) {
|
||||
_isoCollider = iso_collider;
|
||||
}
|
||||
|
||||
public IsoCollider IsoCollider {
|
||||
get { return _isoCollider; }
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools
|
||||
12
Assets/IsoTools/Scripts/IsoFakeCollider.cs.meta
Normal file
12
Assets/IsoTools/Scripts/IsoFakeCollider.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6013de6edf894f15b4b45e011afe2a4
|
||||
timeCreated: 1436271657
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IsoTools {
|
||||
public class IsoFakeObject : MonoBehaviour {
|
||||
@@ -16,6 +18,48 @@ namespace IsoTools {
|
||||
get { return _isoObject; }
|
||||
}
|
||||
|
||||
IsoCollider ConvertCollider(Collider collider) {
|
||||
var fake_collider = collider.GetComponent<IsoFakeCollider>();
|
||||
return fake_collider ? fake_collider.IsoCollider : null;
|
||||
}
|
||||
|
||||
IsoRigidbody ConvertRigidbody(Rigidbody rigidbody) {
|
||||
var fake_object = rigidbody.GetComponent<IsoFakeObject>();
|
||||
var iso_object = fake_object ? fake_object.IsoObject : null;
|
||||
return iso_object ? iso_object.GetComponent<IsoRigidbody>() : null;
|
||||
}
|
||||
|
||||
GameObject ConvertGameObject(GameObject game_object) {
|
||||
var fake_object = game_object.GetComponent<IsoFakeObject>();
|
||||
var iso_object = fake_object ? fake_object.IsoObject : null;
|
||||
return iso_object ? iso_object.gameObject : null;
|
||||
}
|
||||
|
||||
IsoContactPoint ConvertContactPoint(ContactPoint contact_point) {
|
||||
return new IsoContactPoint(
|
||||
contact_point.normal,
|
||||
ConvertCollider(contact_point.otherCollider),
|
||||
contact_point.point,
|
||||
ConvertCollider(contact_point.thisCollider));
|
||||
}
|
||||
|
||||
IsoContactPoint[] ConvertContactPoints(ContactPoint[] points) {
|
||||
var iso_points = new IsoContactPoint[points.Length];
|
||||
for ( var i = 0; i < points.Length; ++i ) {
|
||||
iso_points[i] = ConvertContactPoint(points[i]);
|
||||
}
|
||||
return iso_points;
|
||||
}
|
||||
|
||||
IsoCollision ConvertCollision(Collision collision) {
|
||||
return new IsoCollision(
|
||||
ConvertCollider(collision.collider),
|
||||
ConvertContactPoints(collision.contacts),
|
||||
ConvertGameObject(collision.gameObject),
|
||||
collision.relativeVelocity,
|
||||
ConvertRigidbody(collision.rigidbody));
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if ( !IsoUtils.Vec3Approximately(_lastPosition, IsoObject.Position) ) {
|
||||
transform.position = IsoObject.Position;
|
||||
@@ -26,27 +70,27 @@ namespace IsoTools {
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider collider) {
|
||||
Debug.LogFormat("OnTriggerEnter: {0}-{1}", gameObject.name, collider.gameObject.name);
|
||||
var iso_collider = ConvertCollider(collider);
|
||||
IsoObject.gameObject.SendMessage(
|
||||
"OnIsoTriggerEnter", iso_collider, SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider collider) {
|
||||
Debug.LogFormat("OnTriggerExit: {0}-{1}", gameObject.name, collider.gameObject.name);
|
||||
}
|
||||
|
||||
void OnTriggerStay(Collider collider) {
|
||||
Debug.LogFormat("OnTriggerStay: {0}-{1}", gameObject.name, collider.gameObject.name);
|
||||
var iso_collider = ConvertCollider(collider);
|
||||
IsoObject.gameObject.SendMessage(
|
||||
"OnIsoTriggerExit", iso_collider, SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision collision) {
|
||||
Debug.LogFormat("OnCollisionEnter: {0}-{1}", gameObject.name, collision.gameObject.name);
|
||||
var iso_collision = ConvertCollision(collision);
|
||||
IsoObject.gameObject.SendMessage(
|
||||
"OnIsoCollisionEnter", iso_collision, SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
|
||||
void OnCollisionExit(Collision collision) {
|
||||
Debug.LogFormat("OnCollisionExit: {0}-{1}", gameObject.name, collision.gameObject.name);
|
||||
}
|
||||
|
||||
void OnCollisionStay(Collision collision) {
|
||||
Debug.LogFormat("OnCollisionStay: {0}-{1}", gameObject.name, collision.gameObject.name);
|
||||
var iso_collision = ConvertCollision(collision);
|
||||
IsoObject.gameObject.SendMessage(
|
||||
"OnIsoCollisionExit", iso_collision, SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools
|
||||
@@ -6,6 +6,7 @@ using UnityEditor;
|
||||
|
||||
namespace IsoTools {
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
public class IsoObject : MonoBehaviour {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IsoTools {
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(IsoObject))]
|
||||
public class IsoPhysicHelper : MonoBehaviour {
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace IsoTools {
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(IsoObject))]
|
||||
public class IsoRigidbody : MonoBehaviour {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using UnityEditor;
|
||||
|
||||
namespace IsoTools {
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
public class IsoWorld : MonoBehaviour {
|
||||
|
||||
class ObjectInfo {
|
||||
|
||||
Reference in New Issue
Block a user