// Use this for initialization
        public void Init()
        {
            ChecksumExtractor.Init(this);

            gameObjectMap = new Dictionary <IBody, GameObject>();
            collisionInfo = new Dictionary <RigidBody, Dictionary <RigidBody, TSCollision> >();

            CollisionSystemPersistentSAP collisionSystem = new CollisionSystemPersistentSAP();

            collisionSystem.EnableSpeculativeContacts = SpeculativeContacts;

            world = new World(collisionSystem);
            collisionSystem.world = world;

            world.physicsManager = this;
            world.Gravity        = Gravity;

            world.Events.BodiesBeginCollide += CollisionEnter;
            world.Events.BodiesStayCollide  += CollisionStay;
            world.Events.BodiesEndCollide   += CollisionExit;

            world.Events.TriggerBeginCollide += TriggerEnter;
            world.Events.TriggerStayCollide  += TriggerStay;
            world.Events.TriggerEndCollide   += TriggerExit;

            world.Events.RemovedRigidBody += OnRemovedRigidBody;

            instance = this;

            AddRigidBodies();
        }
Exemple #2
0
        public void Init()
        {
            ChecksumExtractor.Init(this);

            Physics2D.Settings.ContinuousPhysics = SpeculativeContacts;

            TSVector2 gravity = new TSVector2(Gravity.x, Gravity.y);

            m_World = new Physics2D.World(gravity);

            Physics2D.ContactManager.physicsManager = this;

            m_World.BodyRemoved += OnRemovedRigidbody;

            m_World.ContactManager.BeginContact += CollisionEnter;
            m_World.ContactManager.StayContact  += CollisionStay;
            m_World.ContactManager.EndContact   += CollisionExit;
        }
        // Use this for initialization
        public void Init()
        {
            ChecksumExtractor.Init(this);

            Settings.ContinuousPhysics = SpeculativeContacts;

            world = new TrueSync.Physics2D.World(new TSVector2(Gravity.x, Gravity.y));
            ContactManager.physicsManager = this;

            world.BodyRemoved += OnRemovedRigidBody;
            world.ContactManager.BeginContact += CollisionEnter;
            world.ContactManager.StayContact  += CollisionStay;
            world.ContactManager.EndContact   += CollisionExit;

            gameObjectMap = new Dictionary <IBody, GameObject>();
            collisionInfo = new Dictionary <Physics2D.Body, Dictionary <Physics2D.Body, TSCollision2D> >();

            instance = this;
            AddRigidBodies();
        }