Yeah umm I’m making a cool fnaf game and the issue is at the title.
I’m just quiet wondering if i should use OOP to handle the animatronics/monster,etc or i should stick with normal script.
I’d actually say OOP is the way to go for something like that. You’ve got like multiple animatronics doing slightly different things, moving on timers, reacting to doors, cameras, etc. It just makes way more sense to have each one as an object that inherits shared behavior but can be tweaked per character.
You could do it all in a flat script, but it’ll get messy fast once things get more advanced.
OOP is basically made for this. As @xCr_epzz mentioned, animatronics have shared behaviour, while each having unique ones for each animatronic.
Have a main Animatronic class that has the shared methods (i.e, spawnModel()
, goToNextLocation()
, jumpscare()
), and have additional classes (ideally in seperate modules) for each animatronic and their specific behaviours. This is literally what I’m doing for the weapon system I’m working on.
As also mentioned, the number of scripts and code interaction/complexity can increase quickly so take things slow, do research, and consult with AI.
Not taking the OOP approach is fine, but if you value backend quality over visual results, then I recommend investing your time into it.
Oh yeah definitely, especially for animatronics. You’d want something easily reusable and very customizable, both of those OOP provides.
Yeah I agree. As I recently am having to go through an old game (ironically fnaf related) and put everything into modules.
I personally recommend having most things in a module. Have the bare minimum outside of modules, this may seem obnoxious, but it will help in a lot of situations.
Definitely. In fact OOP is recommended since your code becomes much more well organised and easy to read. It is also easy to initialise important objects with OOP. I personally use OOP wherever I can unless its a very small project
it’s fine as long as there’s only a few enemies or less entities and most things are universal enough so yeah, go ahead.
OOP is a tool, you can use it for any game, sometimes it’s efficient, sometimes it’s not
OOP is tool to make a lot of copied data that change throughout the game easy to manage, if you have NPCs and doors and all of that, then OOP will be great to handle these, only remember to dont use it where you dont need to, and you’ll be fine
I agree that outside of the modules there should only be event connectors or standalone scripts that don’t need to be expanded, other than that should be packed into modules
A list of things that you should always use OOP for:
- NPC
- Interactables (doors, pick ups, etc)
- Weapons
- Items
- Area hazards (death parts mainly)
- And a whole lot more I can’t remember
OOP is one of the best tools for it, but it is hard to understand. Class++ makes it easy though. I highly recommend using it