Login

russian armor

Rosbone learns how to make an RTS

11 May 2021, 21:25 PM
#1
avatar of Rosbone

Posts: 2098 | Subs: 2

WTF is this post about
This post will be a list of the events that lead to me making a finished playable 1v1 RTS of some sort. Since I love the Relic worldbuilder and the mechanisms they use, my project will mirror some of the COH2 RTS style items such as Crush maps, Pathing maps, WW2, etc.

Since I am a noob at latter day OpenGL, I will be focusing on game engines such as UNREAL ENGINE and UNITY. I also have no idea how to animate a 3D object so there will be some learning pains involved with BLENDER as well. Since I have a very low IQ (IQ > RelicIQ), progress will be slow.

STEPS TAKEN SO FAR
1) Created a Zombie 3D model in BLENDER with a few simple animations: Idle, Walk, and GetHit.
2) I spent 2-3 weeks learning UNREAL ENGINE. UE can use either C++ or node based BLUEPRINTs to create game code. I took simple BLUEPRINTS to the point of making a simple level with spawning enemies that I could explode and shoot their chunks around. Anything past this I felt I needed to get into C++ to go any further towards an RTS. After watching the UE tutorials made by UE and seeing the C++ crash and not run correctly in their videos, I decided to try Unity. UE also felt like it was trying to to too much. So doing the simplest tasks became very difficult.
3) The first day in UNITY was like a dream come true. Unity was laid out to make games. It was not overly complicated like UE. You could figure things out intuitively where UE required watching a 30 minute video and taking notes or forget it. In a day or so I was at the same point I was in UE. And in the next day or two I had some of the tools to start making an RTS. Stuff I could probably never figure out in UE.

UNREAL ENGINE 3-4 WEEKS PROGRESS


UNITY WEEK 1 PROGRESS



The UE pictures look very sexy. But NONE of the required RTS elements are there.

The UNITY version already has selectable units that move around on a terrain. You will also notice the DEBUG info on the left side of the screen that is missing from UE.

RTS ELEMENTS NEEDED
A) Map making tools. Internal or External.
B) Access to the Height map of the terrain.
C) Access to the objects on the terrain.
D) Ability to spawn objects.
E) Pathfinding code.

A, B, C) In UNITY day 1, I could easily read every object on the map, height maps, etc and save the info to a text file. This means I can use UNITY as my worldbuilder.

I then wrote a C# tool to load the map objects and create/export the IMPASS maps for Low, Medium, and Heavy crush. This will all be done in UNITY at some point.

D) While creating the map and figuring out what scale to use, I created code to just spawn objects wherever I click. Buildings, Units, trees, ground splats, etc. Ready to spawn units and make bomb splats on the ground when they go off.

E) The tool was then used to test FLOW FIELD style pathing code for unit movement (GREEN MAP). this is done here since it is easier to debug and test. Since it is in C# it will work in UNITY when moved over.

Next steps are to implement pathfinding in UNITY and create SQUAD based code. FLOW FIELD pathing is not the best choice for low numbers of units so shall we have squads of 10 guys maybe???

DAY 7 PROGRESS

1) Squad variables created.
2) FLOW FIELD pathing added to UNITY and units path as a squad to selected points.
3) No squad formations yet so speeds are randomized to keep units spread out.
4) Wasted many hours debugging UNITYs shitty ATAN2 function.

DAY 9 PROGRESS

1) Burned out my brain trying to work with the shitty UNITY UI elements. So not a lot of progress. Its amazing what you can do in OPENGL with two commands requires 47 steps and two YOUTUBE videos and a bunch of UI components. I really think I should see what OPENGL commands I can write in Unity. I have heard rumor it is possible.
2) Made a UI Health status icon that hovers over the units similar to COH2. COH2 selects a certain unit and the icon follows that unit. Which is nice because it tells you what unit will go where on the terrain. May have to implement that.
3) Made a small section of railroad and the beginnings of a munition point. Not sure what to do for points. If they are too big they should block sight/shots. No one wants that.

NOTES: Had the epiphany that each player should have a dedicated FLOW FIELD retreat map created at the start. Since any retreating unit can use it, that means NO PATHING CALCS will ever be required for retreats.

Currently running the default UNITY pipeline. Which has no SPLAT or SPLINE capability. There are two other render pipelines to choose from including the High Definition Render Pipeline. The HDRP does allow SPLATS (decals). Nowhere near as ez to use as Coh2 though.

Since I have worked in the Quake 3 map editor for years I am running an awesome version called OpenRadiant that exports maps as Wavefont OBJ 3D files (The person who wrote this is a legend). Then the OBJs get loaded into Blender and exported as FBX, which UNITY deals with better. Made the houses, boxes, railroad, and muni point in OpenRadiant.

Radiant is the best editor for fast simple 3D objects.
COH2 Worldbuilder best for terrain based editing.

DAY 12 PROGRESS

I keep getting hung up on little things so progress has been slow.
1) Created 3 squad types for USF.
2) Created health bar icons for squads and tanks.
3) Created resource income for manpower, munitions, and fuel.
4) Created simple models for Manpower, munition, and fuel points. Each has its own icon with health bar for capturing. Points are also capturable and add to resource income.
5) Added MOVE TO UI graphic for user clicks on terrain.
6) Began particle system tracers for weapons and tank fire. Still very early.

DAY 13 PROGRESS

1) Reworked Camera movement to be more precise.
2) Added basic MiniMap. Can click the map to move camera and right click to move units. No double click yet.
3) Added VORONOI calcs in C# Map program. May start the territory drawing code soon. Should be straight forward.

The next large piece is probably Fog of War. May have to buy something from the Asset Store for the current version (may not be able to write shaders etc).

DAY 15 PROGRESS

1) Added FOW with sight blocking. I added a plane over the terrain and write calculated FOW data into the plane texture. It is a hack that will only work for flat terrains.
2) Created a new sight check algorithm based on spiralling out from the position we are in and checking off degrees in an array if they are blocked. It is not perfect but runs decently for now.
3) Currently using the pathing data for sight blocking. Needs updated to a new sight map.

DAY 17 PROGRESS

1) Added FOW to minimap.
2) Adjusted some textures settings.
3) Created a base HQ building.
4) Created Tank Trap model.
5) Created a burned out Sherman carcass.
6) Started building the UI textures.

It gets very annoying knowing that I can draw the FOW in two lines of code in OPENGL. But it takes a ton of badly optimized code to do it UNITY. Just have to pretend I know nothing about 3D coding.

DAY 19 PROGRESS

1) Upgraded terrain texture quality.
2) Added Precise map for individual pathing on Infantry, Light vehicles, and Mediums.
3) Added Vision map for sight blocking calculations.
4) Added Infantry cover map. Currently set unit decorator with cover color.
5) Tagged all objects on the map with their Sight blocking, Pathing, and Cover settings.

DAY 21 PROGRESS

1) Reworked the unit information icons. Player count background changes color when in cover.
2) Added VP points and code.
3) Added time clock.
4) Added simple AI. Spawns units and takes points. No combat yet.
5) Spent hours trying to get Unity to put the health bar back where it was supposed to be after editing the unit icons. And then I nearly formatted my hard drive and ate some cyanide. Unity UI system sucks ass. One line of OpenGL code = 47 adjustments and settings and code in Unity.

DAY 27 PROGRESS
Not too much progress. Made a post below with details.
1) Started combat engagement code.
2) Setup some tables for damage, rate of fire, etc.
3) Added COROUTINES to smooth out FPS dips.
4) Reworked AUDIO to create a 3D feel in stereo.

DAY 29 PROGRESS

1) Purchased a 3rd party package to allow for splats. Took some time to learn and am not 100% I will keep it. For now it is doing fantastic job but has some glitches in the current version of Unity. Still no SPLINES. I have seen a couple 3rd party apps but will wait to purchase.
2) Made a couple textures to test the new splat tools (all except crater under tanks which is vCoh until I make a new one).
3) Currently only using STATIC splats. Meaning they are done at edit time. The tool is capable of some DYNAMIC splats (done at runtime) but I have not looked into it yet.

DAY 35 PROGRESS
Progress has slowed. Had a few RL things pop up etc.
1) Unity has a cool feature where it never crashes. If your code sucks, it will just jump out of your routine and keep on trucking. This is bad when your code is mostly working but things are acting bizarre. Took a while to track down a few bugs that worked 90% of the time.
2) Added a TRACER look to units firing.
3) Added some home made Unit movement and death sounds. They are very bad.
4) Added retreat button and hotkey.
5) Added reinforce button.
6) Added AI retreat and reinforce code. Set to retreat on 50% squad health.

DAY 55 PROGRESS

1) Been working on getting tanks to move around and shoot. For infantry tanks shots are AOE only. And for other tanks, direct hits only. It is super fun when the tank models are not rotated where they should be and Unitys rotations are backwards. It really starts to screw with your brain.

2) Added Infantry and Vehicle kill counts to UI.
3) Added unit selection icons just above the menu. These are top right screen in Coh2. Which is really far from the menu. So for casual mouse only play they are at the bottom for now. Maybe have options where to put it later.

Still moving very slow. It is summer here and RL is busy. Since I now have tanks working, I need to create some form of anti-tank squad. There are AT weapon models for the squads. Until now I have been using the prefab models so I will need to make my own for AT. Maybe I should just quit :)
14 May 2021, 07:43 AM
#2
avatar of Felinewolfie

Posts: 868 | Subs: 5

Paying attention :)
15 May 2021, 05:38 AM
#3
avatar of Rosbone

Posts: 2098 | Subs: 2

Paying attention :)

:foreveralone: Tell Relic I am coming for that ass!!!

Jokes aside, I am not that smart. So hopefully I can motivate some smart person to make a cool game for us.
15 May 2021, 06:34 AM
#4
avatar of gunther09
Donator 22

Posts: 538

uff, respect for trying this!
15 May 2021, 08:24 AM
#5
avatar of blvckdream

Posts: 2458 | Subs: 1

Interesting project. Keep going.
15 May 2021, 09:45 AM
#6
avatar of Sturmpanther
Lead Strategist Badge

Posts: 5441 | Subs: 35

Looking forward
19 May 2021, 09:28 AM
#7
avatar of Spanky
Senior Strategist Badge

Posts: 1820 | Subs: 2

Well done so far! Keeping an eye on the progress. :)
20 May 2021, 02:51 AM
#8
avatar of Rosbone

Posts: 2098 | Subs: 2

Not sure if I should keep posting in the main post? It may get really long. But it keeps it all easy to read for now :)
20 May 2021, 03:59 AM
#9
avatar of Gbpirate
Senior Editor Badge

Posts: 1150

This looks really neat!
20 May 2021, 15:27 PM
#10
avatar of Olvadi

Posts: 43

do you have sort of patreon or something like that where we can support you? :)
20 May 2021, 16:02 PM
#11
avatar of Rosbone

Posts: 2098 | Subs: 2

jump backJump back to quoted post20 May 2021, 15:27 PMOlvadi
do you have sort of patreon or something like that where we can support you? :)

So far I have invested 2 weeks of my time and about $20 US for the soldier models. How much would people need to invest to pay me back for my time :foreveralone:

Seriously though, if it ever gets to a decent state of play and we want to make it a real game, it may be good to pay some people to make assets like models, art, etc. But that is a long way away... or is it :megusta:

EDIT:
The game will also be free to play if you post "Relic hurt me in my No-No Hole" in the Shout Box!
23 May 2021, 06:22 AM
#12
avatar of Rosbone

Posts: 2098 | Subs: 2

I thought I should talk about the way I am checking the FOW.

DEMO FOW CHECK
BLACK = Unit position, RED = Sight Blocker, GREY = Vision


Standard FOW is usually a simple circle based on the distance from the UNIT. COH2 also checks for sight blocking on objects in a 2D top down fashion.

Originally I planned on drawing a line from the unit position to the outside perimeter of the sight circle. Drawing lines can be very slow and the same points can get checked over and over. Could have a 2nd map that flags if a point has been checked or not.

To try and optimize I came up with this algorithm.

KNOWN DATA
Working in 90 degree increments I know how many degrees each pixel blocks.
Angle = 90 degrees / Number of pixels
Each row grows by 2 pixels and moves up 1 pixel.

The 1st row only has 3 pixels: 135, 90, 45 and each pixel is worth 30 degrees.
The 2nd row has 5 pixels: 135, 112.5, 90, 67.5, 45 and each pixel is 18 degrees.

I created an array with 360 elements that represents 360 degrees of clear vision.
When I hit a blocked pixel I check off the angles in the array that pixel represents.
Any pixels checked are first checked against the 360 degree array.

In our example, the white pixels above the RED line are flagged as blocked by the 360 vision array test.

Algorithm
- Loop left to right each pixel/texel row.
- Check each pixel for 360 degree vision blockage.
- Check if pixel is within vision range distance.

This is done for each of the four quadrants: Up, Down, Left, Right.

Currently this gets checked for each individual unit on the map. Could simplify it to a calc for a SQUAD. But for now, the frame rates seem to be holding up fine.
26 May 2021, 00:25 AM
#13
avatar of Rosbone

Posts: 2098 | Subs: 2

For you guys building your own RTS this is what I have so far...

Still trying to figure out how to handle all of the different mappings for Pathing, Sight, and Cover values(PSC).

Currently I am using a bit mask method where each byte in an array represents the PSC elements.


BIT 0 = Infantry Pathing
BIT 1 = Light Vehicle Pathing
BIT 2 = Medium Pathing
BIT 4 = Sight Block or not
BIT 5 = Light Cover
BIT 6 = Heavy Cover
BIT 7 = Building Cover
BIT 8 = Static or not

The PRECISE map is a blend of the three pathing maps.
The COVER map is a blend of the three cover maps.

Vehicles are larger than infantry and therefore require more room to get around. So blocking objects are increased in size.

Cover needs to surround the objects it is using for cover, so its size is also increased to create a reqion around it where units are standing in cover.

Since my code is pretty bad, any unit in cover sets the squad to that cover value for now. Will update it soon maybe. Maybe average all of the individual units cover values?
Pip
26 May 2021, 13:37 PM
#14
avatar of Pip

Posts: 1594

Suggestion:

Try out Godot. That's what I use for game development, it supports a variant of Python (GDscript) but also C++ and C# (Though I don't know why you'd use C# over C++ if you have the option), and also most other languages through bindings.

It handles 3d, though admittedly the documentation is not as good as Unity.

I havent had a /ton/ of experience with Unity, but it's possible you may find Godot to your liking, and it's perhaps a good idea to have a look at all available tools while you're still /fairly/ early in the project.

Also: Can you perhaps go into more detail regarding your bit mask method for mappings? I'm not entirely sure what the purpose of your system there is.
26 May 2021, 20:42 PM
#15
avatar of Rosbone

Posts: 2098 | Subs: 2

jump backJump back to quoted post26 May 2021, 13:37 PMPip
Try out Godot.

Also: Can you perhaps go into more detail regarding your bit mask method for mappings? I'm not entirely sure what the purpose of your system there is.

I will take a look at Godot. At first glance I dont see much about terrain editing or grass etc. The key piece of an RTS is the terrain editor. Both UE4 and Unity have decent editors. Neither are remotely close being as good as the COH2 editor.

I dont really have a point for why I am packing the map pathing info into a byte array. One thing that helps games is having a small amount of code and data to deal with. Processors have several levels of memory. Each level is faster than the next. If you can get your main code to run in the L1 cache it will run faster.

So the idea was to have a single array that holds all of the pathing, sight, and cover. Probably makes no difference at all in the real world. Because any speed you gain in memory cache you may lose in bit masking calcs. But a single AND command is probably much faster than reading in data from memory.

To check sight for instance:
if (0 < (Map[x,z] & 8)) SightBlocked = true

This adds a cpu cycle calc where we use AND to mask our byte( & 8 ). However reading data from memory make take up to 30 cycles waiting for the data to be pulled into cache if we have a lot of separate arrays.

I will probably end up splitting things because "What happens when the object creating the COVER is destroyed?" I need some method of tracking what is creating the cover. I most likely have to calc all of these maps on the fly. Right now they are static.
27 May 2021, 00:12 AM
#16
avatar of TheMachine
Senior Caster Badge

Posts: 875 | Subs: 6

3 Jun 2021, 03:47 AM
#17
avatar of Rosbone

Posts: 2098 | Subs: 2

DAY 27 PROGRESS
Not too much progress over the last few days. But I did come across some useful things about UNITY I thought I should share for developers.

After adding a bunch of code for Pathing, Fog of War, Enemy Combat, etc, Unity started to slow down to the point of missing mouse and button events. I wrote some code to track FPS min/max. And during heavy code usage, the min FPS was around 30. This only lasts for 1-2 frames then pops back up.

So I stopped adding new things and started optimizing a little.

COROUTINES
I am a noob at Unity and did not feel the need to start MultiThreading the app just yet. But I did want to try using COROUTINES.

COROUTINES give you an ability to do some work in a function, give up control for a frame, then return to do more work. So it spreads heavy calcs out over time. This was very useful in the FOW calculations since I only want to update it once per second or so. Just sprinkle in some YIELD RETURN NULL commands throughout and you are good to go. No more missed clicks or presses.

AUDIO IN UNITY
I also wanted to spend some time getting the audio to play in a 3D mode. UNITY only has one normal 3D command that lets you play a sound in 3D space. However, it rudely sucks ass. Decent for one sound if you dont move. Multiple sounds and moving just created random muted noises and volumes. Horrible.

Luckily I found this guy on YouTube and his tutorials are always fantastic.


This gives you great control and management of sounds but only in 2D. Which is all I am shooting for at this point. Just a couple distance checks and I can set volume and pan of sounds with no glitching or warbling.

Good enough for me.
11 Jun 2021, 01:43 AM
#18
avatar of Rosbone

Posts: 2098 | Subs: 2

Just a note on one thing I am working thru:

You want your units to:
- Do a certain damage per second.
- Fire at a certain rate.

Once I got units firing and making sounds I realized you need to randomize the firing or it sounds really bad. Everyone firing like a clock, etc.

For now I have randomized the firing rates. This also creates some randomness to the fights and outcomes.

I could randomize it for one shot, then invert that for the next shot. So they are random but still fire at the same overall? For example shoots every second so shoot at .9s and then at 1.1s the next time.

But this has me thinking about is this one more thing that Relic does in Coh2 that creates randomness in fights?
19 Jun 2021, 21:27 PM
#19
avatar of Rosbone

Posts: 2098 | Subs: 2

After spending so much time in UNITY and finding out how buggy and poorly laid out it is. I am seriously considering stopping this project.

Unity is about 5 years away from being useful and completed. It feels like you are running a ALPHA/BETA at all times. Some stuff is neat. But others are infuriating or just dont work all together. The help documentation is horrible in that it is incomplete. You have to watch a YouTube video from some 12 year old in a 3rd world country to get the correct information.

I am finding myself coding AROUND Unitys issues instead of just coding the game. Things that are simple and 4 lines of code are taking days of troubleshooting and searching the web to find answers to get around Unitys bad implementations.
25 Jun 2021, 20:12 PM
#20
avatar of Kurobane

Posts: 658

Unreal Engine probably would have been better
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

429 users are online: 429 guests
17 posts in the last 24h
43 posts in the last week
97 posts in the last month
Registered members: 44644
Welcome our newest member, felayo364
Most online: 2043 users on 29 Oct 2023, 01:04 AM