Tuesday, 15 September 2015

c# - choppy/ Laggy sprite animation using Farseer Physics -



c# - choppy/ Laggy sprite animation using Farseer Physics -

so using farseer physics in 2d platformer making, reason makes animations choppy , it's irritating. have tried 2 different sprites. first had 4 frames other had 10 frames. animation choppy when using farseer.

here code create body sprite:

public void createbody(world world, float density, vector2 position, object userdata = null) { //magic number; player doesn't silly running isn't touching because of weapon-- alter later _body = bodyfactory.createrectangle(world, convertunits.tosimunits(_attackforkframes[0].width * _scale.x - 20), convertunits.tosimunits(_attackforkframes[0].height * _scale.y - 2), density, convertunits.tosimunits(position), userdata); _body.bodytype = bodytype.dynamic; _body.restitution = 0f; _body.collisioncategories = category.all;//category.cat1; _body.collideswith = category.all;//category.cat10; ...

here code updating position:

_body.position = new vector2(_body.position.x + convertunits.tosimunits(_movementspeed), _body.position.y);

i convert _body.position display units.

you manually setting position of physics body, in simulation world. great if initializing object, however, when simulating bad idea.

farseer handle, example, collisions in background. applying various forces bodies in world. when move it's position, not next rules of physics engine, manually moving object in world.

what want apply forcefulness instead of manually moving body. seek playing with:

body.applyforce();

c# monogame physics-engine farseer

No comments:

Post a Comment