android - LibGdx Setting Velocity -


how can set linear velocity in x direction without effecting motion of y direction body in libgdx box2d. applied impulse body make jump want move towards right or left tried applying following method:

setlinearvelocity(vector2) 

but stopping vertical motion. thanks

just retrieve current velocity via getter, manipulate , set new one.

vector2 velocity = body.getlinearvelocity().cpy(); velocity.set(500, velocity.y); body.setlinearvelocity(velocity); 

Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

java - gson parse items from comma-separated-value string within a json value -

collision detection - C++ library for mesh to mesh intersection: what is available? -