I want to make a game whose core concept is similar to Pocket Tanks. However, I want to make it more detailed so I wanted a more realistic shell drop-off dependent on shell velocity, whole gun recoil based on the shell weight etc. based on the propellant weight and the vehicle weight. How could I make this as realistic as possible and would I be able to pull it off with just the parameters I listed above? I don’t have any exact values (except gravity) since the game is still just a concept but you can imagine shells being bigger than humans, weighting at minimum 500kg and artillery firing it being over 1000 tons. Would these huge measures cause instabilities and how would I go around them?
“Realistic” is a rabbit hole; you’ll need to decide how much realism you want. For example, are you planning on modelling wear on the gun barrel?
Ballistics equations are relatively simple, and Godot has a lot built-in. You shouldn’t have any problem building this. You might want to pick up (say):
Which I found to be reasonably readable even if you find math a bit off-putting. You don’t need it to do ballistic physics in Godot, but it will potentially help you understand what’s going on and the math involved. There are other similar books out there as well; this just happens to be the one I have.
I wouldn’t worry too much about the scale. Godot is using 64bit float values and AFAIK the integrators are decent, so you should be able to get reasonable results for anything from launching shots the size of a grain of sand up to hurling fever dream gigaton cannon balls around.
high values could cause instability for physics’ floating point values, but you can choose your game’s units. For example you could denote everything in hundreds of kilograms instead of the default kilograms, but it may be more annoying to deal with than helpful as your units don’t seem that outragious. Floats become more of an issue with large space-travel games where you are moving to distance 10,000,000 kilometer apart planets.
For the accuracy of physics you could get pretty far with RigidBodies, they are a little tough to work with but you can get gravity and recoil with a few lines of code.
@gertkeno Can I use RigidBody2D for an object that’s also operated by player? I would have a locomotive move forwards/backwards to attach to the canon (RigidBody2D object) which would then move with the help of the train but I will also be able to use that canon to aim it, load it etc.
Yes, instead of setting position yourself as one would with Node2D types, nor using move_and_slide like CharacterBody2D you would need to use forces, usually by apply_central_force (for consistent movement) or apply_central_impulse (for recoil)
There are many joints to help too, I’m sure a PinJoint2D with it’s angular limits will come in handy when aiming the canon
are you planning on modelling wear on the gun barrel?
No, I am not. That would go far beyond complexity of the game I have imagined for now.
Thank you for the link, I’ll check it out!
I have only one more unrelated question that’s more about the game structure: Should I have a tutorial level that I should use for building the mechanics and shooting targets? Do you think having a sidescroll ‘platformer-ish’ campaign would be boring after some time, is there a better system for this rather than a long 2D platformer campaign?
Unless your mechanics are pretty intuitive, you should probably have some sort of tutorial, but it doesn’t need to be a separate level. It could be a relatively safe area at the beginning of the first level where the player can mess around without consequence and where some prompting is available. That can be as simple as some text on a billboard in the background and a “target range”, for example.
You could also do a full separate tutorial level, but I’d avoid that unless it was strictly necessary.
I’m (probably) doing a separate tutorial mission for my current game, but I’m doing that because the levels are randomly generated, so there isn’t an easy way to insert tutorial stuff in them.
As for the question of whether a sidescroller campaign would be boring, I think that mostly comes down to design. Level design is still more an art than a science, but essentially you probably want to do a few things:
Make sure the player has three (or so) tiers of goal: “beat this enemy”, “beat this section”, “beat the level”. Ideally you want them to have all three goals in mind, and you want there to be tangible challenges at all three tiers that the player understands.
Change things up; if the player is doing exactly the same thing over and over, they’re probably going to get tired of it. Maybe the first enemies are out in the open and don’t shoot back. Gradually introduce new types that are more dangerous, or required different techniques (or maybe different ammo) to deal with effectively.
Slack off occasionally; if a level is big, give them breathing spaces. Having to be constantly running full tilt is exhausting. Also, sometimes people need a washroom break, or get called to dinner. Give them safe spots where they can put the controls down and walk away for a bit.