Help with Enter/Exit modified for a turret or cannon in C#
Hey all, first post!
I'm running into some trouble with the game I'm creating. The core game play revolves around getting in/out of defensive turrets and using them to fight waves of enemies. All of my coding knowledge has been self taught through books, following tutorials and watching videos but I cannot grasp how to get my FPS character to do this. It's weird how simple of a mechanic this is, especially how commonly its found in shooter games and yet there is so little detail on how to go about doing it. I've been trying to use some modified code of getting in/out of vehicles but so far no luck. It would be awesome to have a "Press E to enter" on the GUI show up when within distance of it too.
I'm not looking for someone to write the code for me, I just need a little guidance. I've scoured Google and these forums even for any help at all. Anyone out there got any advice for me?
Answer by Commoble · Mar 05, 2017 at 05:22 AM
Part of making a game is taking large problems like this and figuring out how exactly to do them. A good way to approach this problem is to break it down into smaller problems, then breaking each of those problems into even smaller problems, until your problems are small enough to handle fairly easily. This is a fundamental component of engineering, and software engineering is a big part of making a game.
This problem you've brought here is broad to ask in a single question or solve in a single answer, but I can help you start on it. Some of the smaller problems that I can see you'd have to break this down into are (in no particular order):
Detect when a turret is near or in front of the player
Switch control from the human character to the turret or vice-versa
Animate the transition into and out of the turret, if necessary
Stop the human character from physically interacting with things he shouldn't when he's in the turret or mounting/dismounting it
and anything else you decide that your game requires for this
What I do when I come to a big, overarching problem like this is I write down things I need to do to get it done, finding smaller and smaller things to do until I can't go smaller, until I have a big list of things to work on, then I start doing each of these one at a time. If I think of additional things I need to do or things that would make the game better while I'm doing this, I write those down too, either on my immediate to-do list or "don't forget to do this eventually" list.
Again, the details of you accomplish all of this is up to you. The bullet points above are a good start, but there may be more things you need to account for, or some of the things I mentioned might not apply to your game. Above all, don't be afraid to be creative!
Try your best to break down your problems as small as you can, and give each of your smaller problems your best try, too. The smaller your problems are, the easier they'll be to solve, whether from your own knowledge, or by more clearly seeing what specific bit needs to be googled, or by asking us -- the smaller the problem is, the more detail we can give you in our answers. Coming to us with big problems just gets you long-winded motivational speeches at best, and typically a lot less than that.
@Commoble Thank you so much for taking the time to write that up! That's exactly the nudge in the right direction I was looking for; I'll write it all out on paper and break it down into the basic manageable pieces and then fit it together in a cut down test project.
It's hard to think like a programmer; but we all have to start somewhere, right?
Cheers
Your answer
Follow this Question
Related Questions
Enter door? 1 Answer
normalize two angles, then modify the result? 0 Answers
Limit vertical rotation of Camera 5 Answers
transform.Rotate having no effect 0 Answers