Looking for advice for a punch and knock off platform game.

Hi there,

I’m new to Unity, C# and game dev, though not new to programming and I know Javascript well. I also know PHP well so C# seems easy to pick up, and I’m guessing C# is the preferred language to code with in Unity but I’ll figure that out eventually. I’m really enjoying getting more experience under my belt so that I can make a pretty ambitious game eventually. To start I’m just going to make a couple simple games and have started one which I’ve broken into 4 stages. The first stage will just be the player and an AI try to knock each other off the platform. The last one left wins.

My ultimate goal is to create a sort of procedurally generated, sandbox survival game with realistic, smooth and destructible/mineable terrain. I know lots and lots of people are doing that sort of thing but I don’t care. This is more of a hobby for the time being and I intend to keep working on it as long as I live. I have some interesting ideas and have friends with interesting ideas. I used to run a Minecraft server and a 7 Days to Die server so this is why I want to make this sort of game. I’ve coded several Minecraft/Bukkit plugins as well. That’s the kind of game I want to make because that’s the kind of game my friends and I want to play. I will do it, it’s only a matter of time until it becomes playable. I will not be swayed and I will not give up. I’m already playing it in my mind =)

I’ve looked through a whole bunch of assets on the asset store but I’m just not sure exactly which ones to use yet. Ideally they would have the source available too in case the developer ever disappears or whatever, and hopefully the asset also wouldn’t make things more complicated in the long run like playMaker might. I haven’t bought any of them yet and I don’t have a lot of money to spend yet but would consider spending $100 or so on assets if they would help me create or would be required for this sandbox survival style game I’m going for. Do you have any suggestions I should take a look at or any absolute must haves? I spent so long looking through there I just don’t really have the experience yet to know what the best things are for what I’m attempting to do.

I found the free Standard Assets package and thought it would be a good place to start with the first simple game. I’ve managed to use the third person characters, AI and cameras from that and customized it a bit and created a character and an AI and I got the AI to follow me around and push me off the edge of the platform. I figured out how to make the camera lock to the y position instead of following me to my death. However I’m having a few issues and thought I should ask for some help.

I’ve discovered it’s probably best to use colliders instead of ray casting for the punches and knockback but I’m having trouble wrapping my head around which steps to take to implement a punch knocking the other character back, including the animation. I’m not sure if I should just attach a collider to the player and the AI character and try to use triggers somehow or really how to properly even do that or if I should somehow attach things to the animation somehow. Maybe I don’t even need an animation at this stage. I don’t really know what I’m even doing and can’t seem to find a good tutorial for that sort of thing. I probably could just use more sleep but I’m really enjoying figuring this stuff out and just can’t stop.

Also which is the best way to determine if the player or bot falls off the platform? I’ve managed to use Destroy(gameObject) in one of the scripts which appears to delete my character when I fall off but the AI still keeps moving around. Should I be doing something else like stopping the AI script from following my falling body somehow after the player dies since it won? I don’t understand why it’s even still trying to follow my body since it was destroyed. Maybe I didn’t actually destroy whatever it was actually following? Maybe it doesn’t matter when the game is over anyway. But in the next stage when I add more AI and in the final stage when I add multiplayer it will matter.

I’m attempting to detect it’s y position and if it goes below -50 it destroys it but would it be better to put a trigger volume below the platform?

Those might be all the things left to figure out for the first stage. Unless there are things I don’t know about that I will run into or think of when I have more sleep. I imagine I’ll have more questions for the next 3 stages. This first stage should at least be a playable game when it’s done anyway.

Thanks for reading if you got this far and for any help you can give!

I don’t want to be that guy, but your first project should be a pacman or a marble madness clone.

You are telling that you never put a pair of ski on, never did exercise for prolonged time, and you want to try to cross the Russian country from left to right.
It is not like you are not able, or you lack skills to do that…is simply that you do not know the basics, and tried it on a smaller scale. This is a recipe for failure, because it will make you frustrated, and you end up abandoning your project, thinking that it is too hard. We all went trough this; if it was simple, we all would make clones of what we like :slight_smile:

IF you still want to do it:

  1. assets are there, depending from what you need. There is no asset that does “what you want”, 100%; there are assets that “does something”; you try them and see if they scale with what you need; otherwise, you have to code them.

Even if you have the source; if things change in the engine, and you have no idea how they work, having the source is as close as having a manual for your car in a language that you can’t read.

$100 in assets is basically nothing; if you plan to be heavyly based on assets, you may end up spending much more than that.

  1. raycasting and colliders: they are physics entities; a collider is like an invisible aura around your fist when you puch, that when intersect another collider, tell the physics engine to do something, based on the forces at play, vectors and such. The concepts are really easy, if you compare them to real world. Check out the videos on youtube that show how to smash cubes wiht a collider, using another object with a collider.

Usually you attach colliders to each; then you need rigidbody component; this give you interactions. Then you need a ground plane so objects won’t fall forever, and change the mass parameters. Higher mass moves smaller mass, like in real world.
Triggers are used only when you DON’T want to use the physics engine. When a collider hit something, you get a delegate, which tell you that something collided with it. At that point you write the delegate extended function, and tell the application what to do when the objects collide. Tags help, otherwise there are various ways to do this.

I did mention before that you learn as you go; so first step should be to understand how physics works in Unity, and there are plenty of free videos out there to start. Add a piece at time and you get progress. It takes time…there is no way around it, so take it easy and do things at your own pace.

  1. if the floor has a collider, you can check when the player or AI is not colliding anymore with the floor, to know if they are still on the platform or not. I believe there is a game tutorial in the training section that show exactly that.
    Once that the AI or player is off the platform, you can use events to tell all the listeners (AI or players) to not look for the fallen object anymore. OR more simply, put a condition on your AI, so if the player or other AI is below 0, they should not follow it.

You can destroy whatever is out of the camera frustrum; you can find the distance easily, and then give the destroy command when the object is out of the camera view.

Try one thing at time; do it piece by piece; design on paper what you want to do, how to do it; then try to implement it.
Once you do that; you will see pieces falling in place more easily; or you will realize that you have to change approach. Good luck with your project!

1 Like

Thank you very much for your response! I really appreciate the time you took to type all that. That’s so awesome!

I also appreciate and understand your first point about not crossing Russia and that’s exactly what I thought I was going to avoid by starting with some smaller games, though by the sounds of it maybe not small enough. The first one I’m trying I thought seemed like a pretty simple concept, just knock each other off a platform, but that’s obviously more complicated than it sounds. I don’t mind though and I won’t abandon it either even though it’s not the final game I’m wanting to make and has nothing to do with it. I am really enjoying trying to figure it out, way more than I even thought I would. This so so much better than making websites!

I have no doubt I’ll figure it out eventually, I always do. I actually end up doing a lot of things that people tell me can’t even be done. I appreciate the advice but I usually just don’t listen to them and find a way no matter how long it takes me. I’m pretty stubborn that way (my wife would completely agree so I know I’m on the right track lol) so no worries there =)

  1. Ok, I thought that might be the case. I know eventually I will very likely have to sink more money into assets or figure out how to make my own but I can’t spend more money at this time. Eventually though. I don’t plan to be heavily based on assets I just thought maybe if there are some which might be absolute necessities I may as well just get and learn to use them from the start. I’m just not entirely sure though yet how it all works so maybe I will have to give that more time then. I don’t understand if the sales are worth it or anything because I don’t really know what’s what yet.

  2. I guess I must have to wrap some colliders around my fists somehow then. I was trying to use a sphere collider placed in front of the character and was thinking of how to check if anything is in it when I press a mouse button but maybe that’s wrong then and I couldn’t figure how to do that. I’m maybe confusing the raycasting with colliders or something. I guess I will just have to look up some more tutorials and experiment some more. I was having troubles finding any good tutorials for that, probably because I didn’t know exactly what to look for but I will try searching some of the things you suggested and see how that goes. Thanks!

  3. I will see if I can find that tutorial and see if I can figure that out. I wonder what the difference is to how I tried it with just checking if the player is below -50 y. Maybe it’s more resource friendly or maybe there are other reasons to do with other possible functionality which could be added. I guess I’ll learn. I like the idea of checking if they are below 0 in the AI script, I don’t know why I never thought of that. Obviously I just have to edit the AI script to get it to do things. I guess I just didn’t understand why it was still trying to follow a destroyed object but then maybe that’s because I don’t completely understand what a destroyed object is or how the engine deals with them. I thought it would completely delete it from the world but maybe there’s more to it. More learning to do =)

I will try scribbling on paper and visualizing things that way, that’s a great idea! I barely ever touch a pencil and paper anymore. That might make things easier to understand and may even make me realize things I never would have thought of. I do have a pretty vivid imagination though which helps with a lot of things but seeing it on a page is totally different.

I did do a bunch of the tutorials and understand some things but it’s a bit different when I try to go and do it on my own. I will definitely go at my own pace and take my time to learn it all and figure it out eventually and nothing is going to prevent me from learning what I have to in order to make that bigger survival style game that I want to make. I’m fine with taking the next 30 years to do it if that’s what it takes.

Thanks again for your time! I’m sure I can figure some more stuff out now that I couldn’t before =)

I agree, you should do what you want; each person learn and fail at different rates; kinda like when our parents tell us to not do this or it will be bad :slight_smile: Some listen, some learn after.

At the beginning, you do not have the knowledge to do many things, which is why people get assets to do a quick prototype of their idea. IF time is not a concern, you can experiment on your own and get things done anyway; saving money. Keep in mind though, that no matter how smart a person is; some concepts take time and experience to be mastered; especially if a person does not even know where to start.

The price reflect the value of the work, for that person. If you ask me if I would pay to get a procedural function done by an asset, I would say yes…because I suck at math, and I have no time to get into that stuff.
At the same time if you ask me to write an AI, I have no issues doing so, because it is second nature to me, to work with FSM. So for the first asset, I would gladly spend a decent amount of money; for the second; I would buy it only if it is better than what I wrote myself, cost not too much and save me time somehow.

George Harrison used to sing “if you don’t know where you are going, any road will take you there” :slight_smile:

Colliders does not have to be the exact shape and size of the mesh on which they are attached to…unless you need precision to that degree. For a punch; it is enough to put any collider, really. Just size and center it correctly, so it hits accordingly to the animation; and you are good to go.
I don’t get exactly why you want raycasting, if the 2 colliders will eventually get in contact. Raycasting works for bullets; because the player may be far away; or a fireball from a mage…whatever it is not implying a direct contact.
All that you need, is collider1 on GO1, collider 2 on GO2; put rigidbodies on both; plug in the animations and once the animation play; the hand move and hit the GO (if in range of course), and then the physics engine does the rest. You only need to trigger with the delegate, when the colliders intersect; the “hit” animation.

Tutorials for this are almost everywhere :slight_smile: don’t look specifically for the puch or the fighting game; but check any basic collider tutorial and extrapolate the info from there; you will be surprised at how many tutorials are out there :slight_smile:

Without the source code and the scene, it is hard to do anything. For each action in mind, there could be 2-3 different implementations. Best bet is to see how others do things; and compare it with what you do. Then you will get to the solution on your own, almost automatically.

Welcome to the magic world of doing instead than learning :slight_smile: Some think that if you watch enough videos, you learn. The fact is that watching alone, without experimenting, is as useful as reading the API manual back to back. You mostly learn when you do something out of your own desire, even just to see what happens if you change something.

As long as you have time and patience, you can make anything you want. Just keep in mind that stats are pretty brutal…out of 100, less than 30 are actually finishing one game from start to end; because they give up before; and only 10 out of these 30 are actually finishing a second game. It is important to find a way to keep motivated; once that is gone, everything is lost.

Good luck!

I completely understand everything you’re saying. No question I have a lot of time and motivation so this is one game that will certainly be playable some day, despite the grim stats. Whether I ever consider it actually finished is another story, it may be more like an ongoing hobby or kind of like an art project which I never stop working on as long as I’m around.

I also don’t like math, it makes my brain hurt, but I have a way of developing my own formulas to make things work somehow. But I think a library or asset of some sort for procedural generation is going to be necessary then because I don’t really want to mess with that too long. I’ve surprisingly managed to get the free cubiquity asset to work somehow so I’m not sure how good that is but I guess maybe it’s a start. It seems pretty neat so far. I was able to morph some terrain and that seems really neat. Looking forward to seeing what they do in their rewrite.

I am definitely figuring this stuff out. I imported a new character and some animations for it from mixamo and got all sorts of those working for the most part (the crouch movement was off by 18 degrees due to incorrect spine rotation since mixamo has an extra spine apparently) and was working on the punches before I pretty much passed out in my chair.

My wife absolutely loves The Beatles. I will have to tell her you said that quote. She even has a shrine for them.

Thanks again! You have been amazingly helpful!

Procedural stuff is brutal, if you don’t have a lots of love for math :slight_smile:

Check what Hello games did, with their No Man Sky; that’s all procedurally generated by math formulas. Maybe if they were making a fantasy MMO, it would not be that great. Instead they used what they are best at, and made it good.

Glad that I may be helpful; I didn’t ship AAA titles, but I’ve been lucky to be in many companies, so where possible, I try to point others to experiment on their own; that’s the fun of developing after all!

Nice shrine BTW; I like Beatles but I like a lot Harrison; very underrated musician IMO.