protected virtual void Collision(GameTime time) { _model.BSphere = ((DrawableModel)_model).GetBoundingSphere(); //Check down collision Vector3 downPosition = _model.BSphere.Center; downPosition.Y += -_model.BSphere.Radius; OcTreeNode node = _octree.SearchNode(downPosition); Console.WriteLine("SERA ESTO: " + (node == null ? "NULL" : node.ModelList[0].Key.ToString())); if (node != null) { if (node.ModelList[0].Key == NodeType.Staircase1Down || node.ModelList[0].Key == NodeType.Staircase1Up || node.ModelList[0].Key == NodeType.Staircase2Down || node.ModelList[0].Key == NodeType.Staircase2Up) { EventManager.Trigger(new EventData_UnitCollision(this, ref node, EventData_UnitCollision.CollisionDirection.Down, EventData_UnitCollision.CollisionSurface.Plane)); _downCollision = true; } else if (node.ModelList[0].Key != NodeType.Ladder) { EventManager.Trigger(new EventData_UnitCollision(this, ref node, EventData_UnitCollision.CollisionDirection.Down, EventData_UnitCollision.CollisionSurface.Box)); _downCollision = true; } } else { _downCollision = false; } // Check up collision Vector3 upPosition = _model.BSphere.Center; upPosition.Y += _model.BSphere.Radius; node = _octree.SearchNode(upPosition); if (node != null) { if (node.ModelList[0].Key != NodeType.Ladder) { _speed.Y = 0; EventManager.Trigger(new EventData_UnitCollision(this, ref node, EventData_UnitCollision.CollisionDirection.Up, EventData_UnitCollision.CollisionSurface.Box, -_model.BSphere.Radius * 2)); _upCollision = true; } else { _upCollision = false; } } else { _upCollision = false; } // Check left collision Vector3 leftPosition = _model.BSphere.Center; leftPosition.X += -_model.BSphere.Radius / 6.0f; node = _octree.SearchNode(leftPosition); if (node != null) { if (node.ModelList[0].Key == NodeType.None) { _speed.X = 0; EventManager.Trigger(new EventData_UnitCollision(this, ref node, EventData_UnitCollision.CollisionDirection.Left, EventData_UnitCollision.CollisionSurface.Box, _model.BSphere.Radius / 6.0f)); _leftCollision = true; } else { _leftCollision = false; } } else { _leftCollision = false; } // Check right collision Vector3 rightPosition = _model.BSphere.Center; rightPosition.X += _model.BSphere.Radius / 6.0f; node = _octree.SearchNode(rightPosition); if (node != null) { if (node.ModelList[0].Key == NodeType.None) { _speed.X = 0; EventManager.Trigger(new EventData_UnitCollision(this, ref node, EventData_UnitCollision.CollisionDirection.Right, EventData_UnitCollision.CollisionSurface.Box, -(_model.BSphere.Radius / 6.0f) - 0.1f)); _rightCollision = true; } else { _rightCollision = false; } } else { _rightCollision = false; } PreCollision(); Position = _correctPosition; PostCollision(); }