Jump to content
  • Advertisement
Sign in to follow this  
dbrock

Player shooting

This topic is 3806 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, Just a simple question, I've added the ability to shoot in my game, but I just slapped it in lazily inside the PlayState class, rather then the player class, when the left mouse button was held down. Just curious if I should be doing this work inside the Attack() method of the player class, or if the Rayqueries should be done else where (perhaps inside their own class). Just looking for some ideas ^.^ Thanks.

Share this post


Link to post
Share on other sites
Advertisement
When the shoot button is pressed call the Attack method for the player tied to that input device. This could have the current weapon generate the bullet, and when the bullet is created it can set up it's own trajectory, or the weapon could define its trajectory for it. The bullet itself could do collision tests on other players and the environment when it updates.

That's what I tend to do anyways. You may also want to have some bullet manager class that you can ask to create bullets for you (i.e. you could provide an initial position and velocity) and then when the bullet manager updates it can update all the bullets in play.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!