c++ - In SFML Why does my projectile slows as it gets closer to target -


i creating small 2d top-down program have projectile created when left mouse pressed. projectile moves toward goal. my issue projectile slows when moves closer goal. should remain same speed. looked normalize thinking have had hard time finding on sfml normalize. did find has not helped.

here update projectile (agents):

void agent::update(const sf::circleshape* goal, sf::time delta) { direction = goal->getposition() - body.getposition(); sf::vector2f newpos = body.getposition() + sf::vector2f(direction.x * speed * delta.asseconds(), direction.y * speed * delta.asseconds()); body.setposition(newpos); } 

ps. have in asseconds instead of asmilliseconds or goes weird , lags.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -