public void DisableColliderCollPair(Collider2D coll1, Collider2D coll2, string key) { // only disable if both are colliders and are enabled if (coll1.isTrigger || coll2.isTrigger) { return; } Collider2DPair colliderPair = new Collider2DPair(coll1, coll2); LogicLocker collLocker = null; if (disabledColliders.TryGetValue(colliderPair, out collLocker)) { collLocker.SetLocker(key); } else { collLocker = new LogicLocker(); collLocker.SetLocker(key); disabledColliders.Add(colliderPair, collLocker); // make sure that objs have a destroy signal component if (coll1.GetComponent <ObjDestroyedSignal>() == null) { coll1.gameObject.AddComponent <ObjDestroyedSignal>(); } if (coll2.GetComponent <ObjDestroyedSignal>() == null) { coll2.gameObject.AddComponent <ObjDestroyedSignal>(); } } // tell the physics engine to ignore collision between the two colliders Physics2D.IgnoreCollision(coll1, coll2); }
void Awake() { // get component references masterComp = GetComponent <ShipMasterComp>(); track = GameObject.FindGameObjectWithTag("Track").GetComponent <GravityTrack>(); // init distance PID controller distanceController = new PID("distance controller"); distanceController.Kp = 300.0f; distanceController.Ki = 0.0f; distanceController.Kd = 50.0f; // init other data maxGrabDot = Mathf.Cos(maxGrabAngle * Mathf.Deg2Rad); restrictedGrabDot = Mathf.Cos(restrictedGrabAngle * Mathf.Deg2Rad); acceptableSwitchVal = Mathf.Cos(sharpSwapAngle * Mathf.Deg2Rad); defaultRailJumpTime = railJumpTimer.timerStart; railJumpPercent = 0.0f; noRailsInRange = false; // tag adjustor names grindLockers = new LogicLocker(); JUMP_SPEED_ADJUSTER_NAME += gameObject.GetInstanceID(); ATTACHED_ADJUSTER_NAME += gameObject.GetInstanceID(); // listen for server detach events EventServerGrindDetached += OnServerGrindDetached; // init grind commands clientGrindHistory = new GrindInputState[clientCmdHistorySize]; }
void Awake() { // get component references masterComp = GetComponent <ShipMasterComp>(); startingMass = masterComp.rbody.mass; // init adjustors maxSpeedAdjustors = new ValueAdjustor(); accAdjustors = new ValueAdjustor(); accLockers = new LogicLocker(); }
private void EnableColliderCollPair(Collider2DPair colliderPair, string key) { LogicLocker collLocker = null; if (disabledColliders.TryGetValue(colliderPair, out collLocker)) { collLocker.RemoveLocker(key); if (!collLocker.IsLocked()) { // tell the phsyics engine to enable collisions between the two colliders Physics2D.IgnoreCollision(colliderPair.coll1, colliderPair.coll2, false); // remove the pair from the dictionary disabledColliders.Remove(colliderPair); } } }