Move projectile in direction the gun is facing
        Posted  
        
            by 
                Manderin87
            
        on Game Development
        
        See other posts from Game Development
        
            or by Manderin87
        
        
        
        Published on 2012-11-27T01:00:19Z
        Indexed on 
            2012/11/27
            5:31 UTC
        
        
        Read the original article
        Hit count: 375
        
I am attempting to have a projectile follow the direction a gun is facing. When using the following code I am unable to make the projectile go in the right direction.
float speed = .5f;
float dX = (float) -Math.cos(Math.toRadians(degree)) * speed;
float dY = (float) Math.sin(Math.toRadians(degree)) * speed;
Can anyone tell me what I am doing wrong? The degree is the direction the gun is facing in degree's.
© Game Development or respective owner