Sign in to follow this  

Player shooting

This topic is 3592 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
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

This topic is 3592 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this