#### Object collision help.

So, I'm making my 2D game but I'm having problems with the collision, I've finally managed to create a function to check the collision which I understand which is like,
C++ Code:
```bool GAME::Character::collidingWithObject(sf::RectangleShape * object) {
double x = Appearance.getPosition().x; //position of character X
double y = Appearance.getPosition().y; //position of character Y
double x2 = object->getPosition().x+object->getSize().x/2; //position of object X
double y2 = object->getPosition().y+object->getSize().y/2; //position of object Y
double sizeX2 = object->getSize().x/2; //size of object X
double sizeY2 = object->getSize().y/2; //size of object Y
double dx = x-x2;
double dy = y-y2;
bool xCollided = false;
bool yCollided = false;
//x_collision
xCollided = true;
}
//y_collision
yCollided = true;
}
return (xCollided&&yCollided);
}```

And the character is basically 36x36 rectangle, but I'm still having problems how to move the character to right position after the character managed to get itself inside the object.
I have some methods to work it with one axis only.. Like it moves the character as far as it can be the nearest to object at X axis.. But when I do that with Y it just goes to pretty random position;

C++ Code:
```		for(int wall=0;wall<5;wall++){
if(W_AROUND.Human.collidingWithObject(&Castle[wall])){
double castleX = Castle[wall].getPosition().x+Castle[wall].getSize().x/2;
double castleY = Castle[wall].getPosition().y+Castle[wall].getSize().y/2;
double cornerRadX = W_AROUND.Human.Appearance.getPosition().x<castleX ? -(Castle[wall].getSize().x/2) : (Castle[wall].getSize().x/2);
double cornerRadY = W_AROUND.Human.Appearance.getPosition().y<castleY ? -(Castle[wall].getSize().y/2) : (Castle[wall].getSize().y/2);
double circleRad = W_AROUND.Human.Appearance.getPosition().x<castleX ? -(W_AROUND.Human.Appearance.getSize().x/4) : (W_AROUND.Human.Appearance.getSize().x/4);