Aim N Shoot question #2:

edited February 2013 in Development
Hi again,
I have a bit newbieish question:
How to make projectile to move in line, for example I am aiming (current mouse position) into sky tile to destroy enemy attack chopper which is in projectile trajectory but is further than sky tile?

Comments

  • edited February 2013 Accepted Answer

    When the projectile is shoooted you associate an angle to them. Then at each frame you make the projectile move like that:

    $(projectile).x(Math.cos(angle)*moveIncremant, true);
    $(projectile).y(Math.sin(angle)*moveIncremant, true);

    Where moveIncrement is the distance the projectile should cross in one frame.

  • thank you,
    will try this out
Sign In or Register to comment.