Exemplo n.º 1
0
    private bool hasCollision; // TODO: temporary, should be handled in TSEntity
    void OnCollisionEnter(Collision collision)
    {
        //Debug.Log(collision.contacts[0].point);
        //Debug.Log(collision.contacts[0].separation);
        //Debug.Log(collision.contacts[0].normal);
        //Debug.Log(collision.impulse);
        //Debug.Log(collision.relativeVelocity);

        if (DetectCollisions && Mode == TSEntity.InputMode.record)
        {
            TSEntity other = collision.gameObject.GetComponent <TSymmetryRigidbody>().entity;

            if (!IsKinematic)
            {
                if (FreezeRotation)
                {
                    entity.Input.AddCollision(
                        other,
                        entity.State.Position,
                        Convert(collision.contacts[0].normal)
                        );
                }
                else
                {
                    entity.Input.AddCollision(
                        other,
                        Convert(collision.contacts[0].point),
                        Convert(collision.contacts[0].normal)
                        );
                }
            }

            hasCollision = true;
        }
    }
Exemplo n.º 2
0
 void Reset()
 {
     entity = new TSEntity(
         Mass,
         Convert(InertiaTensor),
         Convert(InertiaTensorRotation),
         Convert(Vector3.zero),
         Convert(transform.position),
         Convert(Vector3.zero),
         Convert(transform.rotation)
         );
 }