How to approach implementing projectiles like a rocket being shot by a rocket launcher?
I'm looking at implementing a feature that provides the illusion of instant response to user interaction. For example, if a player fires a projectile like a rocket launcher, the lag between user input and system response makes this a bit of a problem. What's the best way to approach this situation?
0
Best Answer
-
I would suggest a simpler approach(explained in the last paragraph), but you can do this but it comes with problems you need to solve. You just need to separate what is displayed from what is actually happening in the synced game. For example you shoot the rocket it displays on your screen but in the synced game your unit dies and the rocket therefore can't launch(Do you really need it to display before it happens in the synced game? is lockstep the right approach at that point?)
Lets imagine doing this with movement in an RTS game. First you would order a unit to move and the unit would move right away on your screen. Then when the rest of the clients get the message you calculate how far the unit should be based on the gap between when you ordered and the unit to move and now and you sync up and let the onsyncedupdate take over the movement. Which seems fine but you are going to have a similar situation to an en passant in chess (https://en.wikipedia.org/wiki/En_passant) where when you move your unit and then it teleports in the synced game you could be teleporting over a position where you would have been killed by a turret and it just let you walk past on the players screen because in the synced game underneath you were never in range. So you would need to rollback the game and recalculate what would have happened for each tick between the move order and the current tick to make sure you calculated the game correctly.(You may have been in range but if the turret was busy for just that one tick where it could have killed you you can't let it attack so you have to rollback and recalculate). I don't know how to do this in TrueSync but perhaps you don't need to do any of this.
What I think you should do and what some other games do is just take the approach of playing a sound such as "Yes Sir!" or something and then putting an animated order cursor around the target to give the player immediate feedback so the game doesn't feel sluggish even though it will take awhile for the rocket to actually launch. This approach ensures the graphics are synced to what's actually happening on everyone's screen.
6
Answers
-
I would suggest a simpler approach(explained in the last paragraph), but you can do this but it comes with problems you need to solve. You just need to separate what is displayed from what is actually happening in the synced game. For example you shoot the rocket it displays on your screen but in the synced game your unit dies and the rocket therefore can't launch(Do you really need it to display before it happens in the synced game? is lockstep the right approach at that point?)
Lets imagine doing this with movement in an RTS game. First you would order a unit to move and the unit would move right away on your screen. Then when the rest of the clients get the message you calculate how far the unit should be based on the gap between when you ordered and the unit to move and now and you sync up and let the onsyncedupdate take over the movement. Which seems fine but you are going to have a similar situation to an en passant in chess (https://en.wikipedia.org/wiki/En_passant) where when you move your unit and then it teleports in the synced game you could be teleporting over a position where you would have been killed by a turret and it just let you walk past on the players screen because in the synced game underneath you were never in range. So you would need to rollback the game and recalculate what would have happened for each tick between the move order and the current tick to make sure you calculated the game correctly.(You may have been in range but if the turret was busy for just that one tick where it could have killed you you can't let it attack so you have to rollback and recalculate). I don't know how to do this in TrueSync but perhaps you don't need to do any of this.
What I think you should do and what some other games do is just take the approach of playing a sound such as "Yes Sir!" or something and then putting an animated order cursor around the target to give the player immediate feedback so the game doesn't feel sluggish even though it will take awhile for the rocket to actually launch. This approach ensures the graphics are synced to what's actually happening on everyone's screen.
6 -
@Zergleb Thanks for your response, it sounds like a good, practical approach to me.0