▲ Watch the devlog on YouTube ▲
Hi everyone, and welcome back to my devlog!
If you’re new here, I post weekly devlogs logging the progress of the new 3rd-person looter-shooter mobile game I am developing, so consider subscribing to my YouTube channel to follow along!
I carried on from where I left off with the shooting mechanics. To recap, the idea is to use two joysticks. One will be for aiming, and the other for shooting and controlling recoil. Aiming was simple to implement, as all I had to do was rotate the spine of the player by the fraction of the joystick moved. Next up however was adding recoil, which was a little trickier. The initial plan was to rotate the player’s spine upwards whenever the player shot, and then use the right joystick to pull down and “control” the recoil.
Once I figured this out, and my player stopped wanting to be elastic girl… I moved onto adding vibrations whenever the player shot.
after play-testing a bit, I felt that having to manually control your recoil was a little too complicated for a mobile game. So instead, I decided on a system that used automatic recoil control, which meant I could then use the shooting joystick for micro adjustments when aiming.
Next I moved onto adding the different trigger types for weapons. By this, I mean that different weapons should fire at different times when using the joystick. Automatic rifles for example, fire when holding the joystick down, while single fire rifles fire when the joystick is released. Throwables on the other hand are entirely different, as when you press the joystick, it should prepare the throwable, and then when you release it, it should be thrown.
I added three events to my custom joystick. OnPress, OnHold and OnRelease, which allowed me to individually set this based on the selected weapon.
Finally, to end the day off, I began creating the system for adding crosshairs.
I finished the crosshair system off, and here are some of the crosshairs I was quick and easily able to put together with this system!
I then moved onto adding a spreading mechanic to the crosshairs.
Once I was happy with that, I got to work on the trajectory system for throwables. Like in PUBG, when you throw a grenade, it shows the path the grenade will travel along when thrown. I used the following formula to achieve this effect:
This allowed me to generate a line renderer that connected a pre-defined number of line segments together to form a trajectory that would show the path the throwable would travel along when thrown.
I carried on with this trajectory system to dynamically update and match the player’s rotation.
I also had to account for an offset so that the trajectory always ended up on the ground and not in the air. I achieved this by calculating the distance the parabola was away from the player at the height of the ground, and then recalculated this each time when rendering the trajectory.
I spent the rest of the day getting this trajectory to show when preparing and then actually throwing a throwable, and this ended up looking great!
I spent the entire day tidying up and optimising all of my code, and once I was happy with that, I implemented the automatic recoil control system, which just gave it that effect I was looking for!
All in all, it was a productive week, and I was happy with the progress made.
Thanks so much for reading, and I’ll see you in the next one… take care!