top of page
Player Movement

The Problem: How to create a dual-stick player movement control system? (Controller, Top-Down, Player Rotation, Player Movement, Shooter)

The easiest part to create was the movement, which was straight forward since it was based on the direction the left joystick was at and simply adding a force to that direction. The big part was tweaking the variables so that the movement would feel smooth and not overpowered. 

After creating the actual movement of the player, I had to figure out how to make the player rotate around itself based on the right joystick. The rotation was also as simple as the movement, I just had to make the player object look at the direction (Vector3) which was based on the x and y-axis of the right joystick.

What became a problem was keeping track of where the gun was located, and how it would orient itself correctly based on where the player is facing. To create that I created a new script that tracked the gun's location. First I centered the gun on the player and based on a right joystick I was able to track and calculate the angle of where the gun would be, by getting the x and y-axis of the right joystick. After getting the angle I applied it to the gun.

Player Shooting

The Problem: How to create a shooter, based on player's gun direction? (Shooter, Controller Shooter, Player Rotation, Implementation of Pistol, RPG, Grenades, Machine Gun)

I started creating the shooting mechanic first based on the player having 4 guns, one gun being a pistol with unlimited ammunition, and the other 3 were a machine gun, an RPG, and a decoy. Based on that I used the similar logic for the gun rotation to make sure that the player had moved the right joystick over the threshold. By moving over the threshold I created a boolean that will indicate that the gun is shooting and added a timer for the delay of every shot. I had the same logic based on the gun that was chosen at the time, what I changed was the firing rate and the function it would call.

For each gun chosen the function of that specific gun will be called. Each gun has its own bullet prefab, scale, velocity, color and sound.


3 out of the 4 guns needed ammunition, so to make that happen I created a script that kept track of the ammo for each gun. As can be seen above after calling the function of the gun it would lower the ammo of that specific gun by 1.


The Problem: How to create a power-up object? (Randomize Power-Ups, Collision, Ammunition, GUI feedback, Player interaction)

Before creating the functionality of the power up box I had to initialize all the variables that I would use to make both the specific amount off ammo added to the correct player's clip, and display it on the GUI. I distinctly defined the GameObjects, TextObjects and Ammo scripts based on which player it belonged to. (1 at the end for Player 1 and 2 for Player 2)

After initialization of the variables, I started checking collision of the Power-Up box with any of the players. As you can see above I had initialized a randomizer called whatPresentYouGet, this randomizer will be checked when a player collides with the box, which will cause in the player getting the ammunition and the GUI to appear.

bottom of page