Handling Enemy Fire

Last post 03-22-2008, 4:22 PM by Giblet. 3 replies.
Sort Posts: Previous Next
  •  03-22-2008, 11:06 AM

    Handling Enemy Fire

    Hey, I currently have two ships chasing each other around each sending packets containing their rotation and position along with a "hasFired" bool.

    Now, if this bool is true, the main game code fires missiles from the origin ships position. I can't seem to get this to work as a once off event i.e: if the other player fires, it fires one missile until the next time. I can, however, set the boolean to true and leave it that way which allows me to watch the other ship fire lots of missiles. The other problem I'm having is that the missiles are client side, which means that the missile only needs  start point and the rest is drawn and positioned by the client machine. It seems as though they both fire at different times, I press fire and missiles stream out my ship, but on the other machine, it doesn' thappen at exactly the same time. I have the game updating network data every six frames.

    Basically what I need to know is, how can I ensure that when I press fire, that a once off fire event happens and is recognised by the remote machines and that it fires the same frame? Can I make it send an update instantly?

    I'm using the tanks prediction sample as a base.



  •  03-22-2008, 11:26 AM

    Re: Handling Enemy Fire

    Ok, I have the fire once event (stupid me, I just always set it to false at the end of the update event). What about client side prediction? How can I approximate the positions as close a possible. I could update the position server side, but I'd like to have client side, as it's smoother looking. (and it's a fire and forget missile)
  •  03-22-2008, 2:01 PM

    Re: Handling Enemy Fire

    Yeah just a brain fart. Basically when I fire a missile, i had previously sent the current position of the ship, I should really have sent the position I was at when I fired the missile to the client. So they are the same. Then on the client side, tell the host if it hit me. Might be problems with lag but I can live with that, sure that's a universal problem.
  •  03-22-2008, 4:22 PM

    Re: Handling Enemy Fire

    Ok, new question along the same vein. I have an event handler for when my ship fires. Is there anyway to send that event across the network?
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback