Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My issue is this: i am making a scrolling game in XNA, and the camera updates based on the players velocity, but the player never actually moves, he is always in the center of the screen. When he hits the top of the building though i want him to always be on top and sink through the texture in a way like this:

enter image description here

what i am doing to make this happen is i am just setting his velocity to 0, so its not moving, but the more velocity he hits a building with the more he sinks through it.

I also tried setting the buildings position to the plays Bounding Box's bottom, and this achieved the look i wanted but this also resulted in the other buildings rising in the air, because the velocity was still moving (even if i set it to 0).

enter image description here

if it was not a scrolling game, this would be not a problem, because you just set the players position to the top of the building, but because the player never actually moves, i actually need to move the camera to the point where the building is under the players feet without the other buildings rising. (Take note this is note a real camera, it is just a class that moves the objects in the world based on the players velocity). All questions are welcome.

share|improve this question
    
Oh so you are making a flappy bird game also? :) In mine what I'm doing is I DO move the character in X space. Then I also move the camera to match the X of the player. But set the camera's look at to be the same x and y as the camera with a the same as the player. I can post an answer if you want me to. –  badweasel Feb 22 at 6:00
    
I don't get it. Why not just set the buildings' bounding boxes to something other than their sprite height? Is this a collision detection problem or a graphical effect problem? –  Anko Feb 22 at 11:10
add comment

1 Answer

One way might be is to add a set of "offset" properties to your player class or allow the ability to offset what the "center position" is.

Move the camera until he is about to sink in, and then change his center position instead of the camera's position. You can then draw the character sunken in without moving the camera around him. Then we he needs to get out of the hole, you can adjust the offset until it is back to the "real center" and then start to move the camera again.

You can see an example here at the one minute mark or anytime a character gets near the edge of the map. http://www.youtube.com/watch?v=7mMJio2MO6w&feature=player_embedded

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.