c# - Camera Jitters Matrix Camera -
i using translation matrix move screen when player collides object player jitter if wants in 2 places @ once. looks velocity wants keep going down while block pushes up, how go fixing this?
video: here
camera class:
class camera { public vector2 position; viewport viewport; public vector2 camerabounds; public float wasground; public matrix transform() { var translationmatrix = matrix.createtranslation(new vector3(-position.x, -position.y, 0)); return translationmatrix; } public player thing(player player) { camerabounds.x = player.position.x - game1.offset.x; if (camerabounds.x > 0) position.x = player.position.x - game1.offset.x; else position.x = 0; //problem camerabounds.y = player.position.y - game1.offset.y; if (camerabounds.y > 0) { position.y = player.position.y - game1.offset.y; if (player.goingup == false && (wasground != player.ground)) position.y = player.ground - game1.offset.y; wasground = player.ground; } else position.y = 0; return player; } public camera(viewport viewport) { viewport = viewport; } } i tried fix problem adding in player goingup , ground if statements did not help.
i solved it. sequence of operations. move method camera.thing() shown below:
// todo: add update logic here handleinput(keyboard.getstate()); player.update(gametime); // delete here time += (float)gametime.elapsedgametime.totalseconds; foreach (block b in blocks) { player = b.blockcollision(player); } // place here camera.thing(player); explanation: have set camera position after collisions have done.
Comments
Post a Comment