Battle pong #4 – Changes of the Rooster year !

Late update but a big one ! As a matter of fact I kept working on different aspects and tried to dig deep into some questions.

Move that body !

Until now I used the keyboard to move the shields but it’s time to prepare the touch behavior. For now it means using the mouse as a touch. I will try to use a joystick  behavior, an idea I got from the KOTOR mobile adaptation. The Idea is to make it simple as possible for the player. So it should do this :


Here is how we try to do this:

  1. Check if the button is pressed
  2. If the button is pressed check if we are dragging
    If we are not then start a drag movement and keep the position for a touch start.
    If we are then calculate the distance between the current point and the starting point and compute the speed from it.
  3. Once we calculated a new velocity, we apply it to the Rigidbody2D
  4. We make sure we stay within the player range by correcting the position if necessary.

Since both players are now linked on the same prefab they both move exactly the same. Since I promised to do screencaps last time so here it is!

Both shields move in perfect sync… It’s kinda artistic !

Thanks to /r/gamedev for suggesting GifCam for this high quality gif. Okay it’s very disturbing to see both shields moving similarly so it’s time to work on AI !

The rise of Skynet…

It’s a pong game so it shouldn’t be hard! The idea would be that the enemy shield will follow the position of the ball more or less quickly and use the speed to modulate the difficulty.

For the first tries it will be a vertically following the ball, I will add a smash option later to make the AI more tricky. It works right now although the move is not that smooth… I have to think of a way to improve that.

What is interesting is one of the first gameplay adjustments since the beginning of the development: I decided to reduce the size of the shield in order to add more pressure on the player. One of the problems with the initial size is that you can quickly reach the top or the bottom on the screen which makes the game a little bit easier.

Player VS AI ! Okay the moves are really not smooth…


First reflection of seeing this? The movement system sucks… I will have to rework it totally.

Second reflection? I have to find a way to disable the collision once the ball is behind the player otherwise the player can hit its own coins just by staying in front of the ball!


Smoother moves

Now to setup smoother moves… Let’s forget the KOTOR movement system ! It seemed like a good idea in but….  It’s a mobile game with a touch : let’s just use the touch position to set the shield. In one picture, it means this:


I already have the mouse position and the drag information. All I have to do is instead of computing a force, I will just set the GameObject.Transform.Position DIRECTLY on the mouse position.

Yeah better !

The movement is smooth but it’s kinda hard to trick the AI with this shield shape… I’ll probably should setup the correct shield shape as soon as possible!

Anyway it’s better but there is a lot of room for improvement. Let’s sum up the work of these past days!

To sum it up

What I learned ?

  • There are many ways to control your player but usually only RIGHT way to do it (Remember the CCC : Camera, Control, Character)
  • I didn’t think about the case where the ball already  went behind the player, so I have to solve this issue.
  • It’s not fun to play with a bar…
  • It’s not fun to play when the ball is too fast…
  • Hey GifCam is easy to use!

Next steps ?

  • Make the right shield sprite to add spiciness to the game
  • Make a script to manage the activation/deactivation of the collider
  • My AI is too dumb, I need to make it smarter!

Anyway thanks for reading!




Battle pong #4 – Changes of the Rooster year !

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s