I apologize if this comes off aggressive, but if one has spent the whole day searching for a key part in every single game and didn’t even get close, then you two would be peeved. I can’t believe there is no beginner course with the minimal outline of a C# script for a Game Manager__ __class. (NOT a Scene Manager, NOT a Singleton, and NOT a Game Controller) I’m working on a final project that revolves around completing a task before the time runs out with types of enemies that push the player instead of kill. It’s a 3D collect-a-thon where the Game Manager should identify objects and when to activate the object’s script and also controls the function of buttons on the screen one of which exits the game. It’s one level and I just need a basic outline for my Game Manager:MondoDevelop__ __class. I know to code the details, but I always forget the simple stuff.
And you’re under the impression that this exact combination of functions is some sort of standard package used in all games? I think I’ve identified why your searches have been unsuccessful.
“Controlling the function of buttons” could mean a few different things, but the simplest case is that you configure each of the buttons to call some function on this object when it is pressed. You can do that by defining essentially any public functions you want and making them do essentially anything you want. (In Unity, there are some restrictions on what kind of parameters they can take in order for them to show up in the Button’s OnClick UI, but otherwise you’re just defining whatever functions you happen to need.)
For the specific case of quitting the game, you probably want the function to call Application.Quit. Depending on the details of how your game works, you may want it to do some other stuff first, like saving the player’s progress.
“Identify objects” could mean any of a dizzying array of different things, so it’s pretty tough to guess what you have in mind there. I suppose the simplest thing you could mean is that it has variables that contain references to other stuff in the game, which you would do by…well…defining variables, and then assigning other objects to them as values (such assignment could happen in Unity’s inspector, via GameObject.Find or one of its cousins, or in any of a large number of other ways).
“Activate the object’s script” presumably just means using one of those variables to call some function on the other object, possibly with the implication of some logic in front of that to decide when and how to do so, which could be, again, essentially any computable logic you can imagine. Calling a function through a variable looks like “myVariable.SomeFunction()”
I basically want something similar to Unity’s “2D Roguelike” but for a 3D game without the level generation.
To Clarify “Identify Objects” is mainly for my enemies who have different behaviors, but have the same result when colliding with the player without affecting pickups. They all also play a sound when the player is close. I want the objects with the enemy tag to push the player in the opposite direction rather than kill the player. Think of it as more of a grade-school bully than murderous psycho.
I haven’t done that particular tutorial, but I would guess that your difficulties don’t have anything to do with the switch from 2D to 3D per se and more to do with the tutorial relying on Tilemaps or some other specialized feature that doesn’t apply to your game. If that’s the case, there may not be a direct equivalent that you can use without completely restructuring how your game works.
If you already have a system where the enemies damage the player when they touch them, and you want to change it so that they push the player instead, just find whatever code is currently dealing the damage and change it to move the player (or apply force, or otherwise modify whichever system you’re using for moving the player in your game).
Note that systems where the enemies push the player run the risk of the player getting trapped, so make sure to think carefully about whether that could happen and what the game should do if it does.
If you’re trying to make a bigger change than that, then you need to break it down into smaller steps. That might involve things like:
- Detect when the player collides with something
- Determine what kind of thing the player collided with
- If it’s an enemy, calculate what direction it should push the player
- Move or accelerate the player in that direction
Very often there are multiple ways to accomplish the same goal. For instance, to know when the player “collides” with something, you could attach colliders (or collider triggers) to the player and the other objects and just functions like OnCollisionEnter. But you also could have a singleton object that tracks the current position of everything in your game and checks each frame how far apart they are by looking at their coordinates.
Also very often there’s more than one way of converting a given goal into a mathematically-precise description. Does “colliding” mean that they have to be in exactly the same spot, or just close together (and if “close together”, then what is the shape of the collision area)? Is it only a “collision” if the player moves into the enemy, or only if the enemy moves into the player, or even if they end up overlapping for some other weird reason? Part of making a computer game is deciding these kinds of details, to change a general concept into a precise model that can be explained to a computer.
Everything @Antistone wrote above is just basic engineering principles, applicable to any type of engineering, including software engineering. Humans generally learn engineering by example, seeing another engineer’s work and saying “I see and understand their thought processes, let’s see if I can do it too.” Fortunately there are thousands of tutorials out there to get you started, and then you need to take it the rest of the way and do the actual engineering to make your game work. That’s how game engineering works.