Really Complex Sprite Movement :)

Or is it? It’s beyond me, so far…

One of my students is creating his game for the final project in unit 3 and has programmed 2 different sets of movement commands for the controlled sprite: one that controls the way the sprite moves around the screen (using wasd keys), and another that controls the direction it faces (oriented towards the worldMouse position). All that works fine. What we can’t figure out is how to fire a projectile in the direction the sprite is facing, such that the projectile continues in a straight line once fired. We can program it such that it moves towards the worldMouse position (which is the same way the sprite is facing), but then it continues to follow the mouse as the mouse moves.

Is there a way to establish an initial vector, based on the mouse position, which the projectile sprite would then follow, even if the mouse changes position after the projectile sprite starts along its path? Or is there another solution?

Set the direction of the fired sprite only once when the mouse is pressed. I could help more if you would send me the link to your code, for now I’m not sure how to help you more than this…