Equipment system

Published on

in

Not in the mood to read?? No problem, test the system yourself here!

General overview

This project serves as a take on a broad equipment system. Although not completely perfected and refined, my goals have been met with creating a system that allows developers to create equipment objects with relative ease. My main goal was to create a system that minimizes the need for developers to manually add and assign component and references. I aimed to create a system that does not require you to create specific prefabs of equipment. I aimed to achieve a ‘Pick a model, add object / script x and play’. I feel like these goals have been achieved. The system works as intended, although it definitely can be perfected and optimized. Down below, I will explain how to to create equipment objects in this manner, and how to implement and expand on it. First, I need to tell you about the present equipment objects and their usage.

Generally speaking, there are 5 types of equipments. These equipments can all be activated to do something. The player is able to equip an equipment in his left or right hand (non visible hand as of now). Pressing a certain button or key activates the equipment for that hand, therefore, there are two activation keys. Other actions revolving around a specific hand also have a specific key for their hand.

Currently, the project features 5 different types of equipment, with each a different activation use.

  • Weapons (ranged). Upon activation, shoots bullets towards the mouse. Can have different fire modes that get switched by FireModeSwap input (see down-down below)
  • Ammunition. Upon activation, reloads the weapon in the other hand
  • Throwables. Upon activation, throws the equipment from hand towards the mouse direction. Forces are calculated depending on mouse target, values can be set per object and can be tweaked.
  • Tools (I.e Flashlight). The Flashlight is currently the only tool, upon activation it toggles the light.
  • Apparel (I.e Hat). The hat is currently the only apparel. Upon activation, the hat gets put on the player’s head. Activating again for an empty hand places the hat back in the hand.

A quick description of how the system works for developers: A Scriptable Object of each equipment type can be made to serve as the data of the equipment. A prefab object with a MonoBehaviour script handles the behaviour of the equipments. It has a reference to the scriptable object for specific values. Another object controlls the system of equipping and dropping. It has references to the Hand scripts and controls the input for activating the equipments. The activation logic is stored in a seperate script. The behaviour script has a reference to this to call the logic. A seperate script automatically adds the correct activation logic script to the equipment based on it’s type, and initialzes it (ActivationLogicHandler.cs).

This system allows developers to create new equipment objects without having to assign multiple component, references and other values. More on how to do this in below section.

Lessons learned

While developing this system, I learned a lot about many things I was unfamiliar with. Not only did I learn about using, implementing and referencing Unity’s Scriptable Objects, I also learned about FPS-like controls, cameras, mouse coordination and creating a multi-usable system that can be implemented in many different ways. I experimented a lot and overcame many challenges, where each obstacle provided more motivation and excitement to work on the next obstacle on the road. I had a lot of fun by challenging myself to make something broad while keeping other devs in mind for future works!

Read Next:



Hey!

Hey there, fellow Robloxian! Whether you’re here to discover hidden gem games, level up your building skills, or just stay in the loop with the latest events, you’re in the right place. This blog is all about sharing the coolest things in the Roblox universe—from developer tips to epic game reviews. So grab your Bloxy Cola, hit that follow button, and let’s explore the world of Roblox together! 🚀


Join the Club

Stay updated with our latest tips and other news by joining our newsletter.


Tags