8
\$\begingroup\$

I'm making a real time shooting game with Box2D as the physics engine. The gameplay is mostly about trajectory, like Angry Birds. I want to make a slow motion effect and move camera to the player when he's killed, but the effect should start when the stone is still in the air, before the collision actually happens.

The magnitude of damage is only calculated at collision, based on impulse. Because it's a real-time game, the player must be able to move their character's physics body without lag.

How can I predict their death? Is it even possible? I could raycast, but what if another object moves to block its path?

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ Theoretical note: The future of non-deterministic systems is by definition unpredictable. See Schrödinger's cat, mentally replacing "cat" with "player character". \$\endgroup\$ – Anko Jun 30 '14 at 20:46
  • 1
    \$\begingroup\$ @Anko very interesting idea! I've never tried that. But the player can still move so where he go or how far he go is not predictable. Yet I know the player's move speed so when the stone is close enough, I know it won't miss... \$\endgroup\$ – Arch1tect Jun 30 '14 at 20:48
  • 1
    \$\begingroup\$ (1/2) IMO it would be much more interesting if you used a raycast to see if a collision has a decent chance of occurring, then start the camera zoom and slow the game down. For every frame, re-do the ray cast to see if the stone is still on a collision course. If the stone is intercepted, the camera should just zoom back to its normal state, but for every frame the collision is still likely, zoom the camera a little more. \$\endgroup\$ – NauticalMile Jul 1 '14 at 14:26
  • 1
    \$\begingroup\$ (2/2) This will kill two birds with one stone (word play not intended): you won't need to do any 'looking into the future', and the players will experience the thrill of near-misses as well as direct (or grazing) hits. In fact, I could argue that your effects will become boring if the player knows that, every time the camera zooms in and the game slows down, he's doomed. He will want to skip the 'animation' immediately and try again. But if there's a chance he can evade the stone, you can bet he will be biting his nails waiting to see the outcome. \$\endgroup\$ – NauticalMile Jul 1 '14 at 14:32
  • 1
    \$\begingroup\$ (1/2)@NauticalMile hey, that's a very good idea too!! I'm afraid it may not directly apply to my game because the player is hit too often, so zooming in and slow motion may interrupt the on-going game too much. \$\endgroup\$ – Arch1tect Jul 1 '14 at 19:29
2
\$\begingroup\$

Why calculate the trajectory for the sounds/slow down effects?

If you split the act of slowing down the camera and playing effects into sections upon approach to your squishy victim then you can essentially play them on condition of their proximity.

This is a great example that comes to mind. The proximity slow down effects employed in Peggle

The ball gets close to the peg and starts slowing down. This is actually based completely off proximity, no trajectory involved. If it gets close enough to the last peg it starts a drum roll and slows the game-play down, if it does not hit the peg and goes out of range you hear "Awww.. :(" and all returns to normal, but if it collides you will get the full fledged Overture and winning screen.

This is a great technique if you approve of making your player go "Holy cow, I nearly got hit!". If you have a start-up sound/effect for a death cam that will play before impact then simply trigger this when the stone is close enough that even if the player moved at maximum speed in any direction - they have a great change of getting squished.

Say your rock is falling and you want to begin the slow down effect to ~4m away from the player: You start by triggering slow-down, move your camera and start focusing on the player - if the rock is then interrupted by other debris then simply exit the slow down focus and your player continues as normal.

enter image description here

This is essentially how Peggle handle their slow down effect and trigger the end game music and is perfectly viable for using on your camera/rock/squishy pre-empting death-scene scenario.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.