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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -