Loading...

Pong World

Pong Circular
Me
  • Date:
    01-10-2016
  • Link:
    Play The Game!
  • Language:
    C#
  • Software:
    Unity
  • Platform:
    Windows, WebGL
  • Type:
    Game Development, Unity

Pong World

This was a fun little project where I tried to recreate a classic videogame with a twist. This turned out to become a circular version of the game Pong.

This version is one player only and controlled with an Xbox (360/1) controller.

I struggled quite a bit with the rotation bit of the game, because rotations are not the easiest things in video games.

Down below you can see the Move() method which was the core movement part of the player. As you can see, it involves quite some math.

private void Move() {
        
        float targetAngle = Mathf.Atan2(input.y, input.x);
        float currentAngle = Mathf.Atan2(thisTransform.position.y, thisTransform.position.x);

        float angle = (targetAngle - currentAngle);


        directionVector = new Vector3(
          directionVector.x * Mathf.Cos(angle) - directionVector.y * Mathf.Sin(angle),
          Mathf.Cos(angle) * directionVector.y + Mathf.Sin(angle) * directionVector.x,
          0);

        Quaternion rotation = Quaternion.LookRotation(directionVector, Vector3.up);
        thisTransform.position = directionVector;
        thisTransform.rotation = rotation;

        if(tookDamage) {
            UIManager.Instance.SetLives(health);
        }
}

The game can be played here: dev.sandordaemen.nl/pong

This website uses cookies to ensure you get the best experience on my website