Skip to content

Conversation

@Ji-Rath
Copy link
Contributor

@Ji-Rath Ji-Rath commented Jul 10, 2022

Early example of simple unit formations. There is still a lot of cleanup to be done but the core functionality is there.

  • 'Rectangle' formation by specifying a FormationLength in the RTSFormationTrait
  • Spawning and shooting entities will appropriately shift the formation to fill any gaps
  • Encapsulated in a plugin (though it does depend on some things in the project)

image

MassSample-Formations.mp4
MassSample-SpawnUnits.mp4
MassSample-DestroyingUnits.mp4

Known issues

  • When spawning a large amount of entities (>100) actor visualization appears to stop functioning. May be unrelated to my code.
  • Performance was not a priority so some things can definitely be optimized
  • URTSFormationInitializer does not properly handle entity destruction. It is temporarily handled in the subsystem.
  • A few processors are bundled together. For readability, I might separate them in the future.
  • Unit movement is not implemented but should theoretically be straightforward.
  • When units are destroyed, the entity index is sometimes not properly handled.

stefan-zimecki and others added 16 commits June 3, 2022 00:45
Added a sample & demo on how to handle per instance ISM data.
Additional clarification of a processor
Per instance Material data from a Processor to Instanced Static Meshes sample
Add basic square formation with x amount of units
Add shared fragment to modify formation sizes
Add some additional comments
Refactor RTSAgentTraits so that traits/fragments are separate from processors
Streamline logic so readability is more of a focus over performance
Update RTSFormationExample map
@Megafunk
Copy link
Owner

When spawning a large amount of entities (>100) actor visualization appears to stop functioning. May be unrelated to my code.

The visual quantity limit is probably the in the LOD parameter config. I'll definitely look at this soon, still shoveling the rest of the project into plugins.

@Megafunk Megafunk force-pushed the main branch 2 times, most recently from de84429 to 0560342 Compare July 11, 2022 06:35
Ji-Rath added 10 commits July 11, 2022 08:37
Add simple actor visualization for entity destruction
Experimental changes for resolving Visualization
Add simple check for entitysubsystem
Allows player to create entities to add to the unit
Optimize adding and removing entities from unit (unit index of swapped unit still needs to be resolved)
RTSFormationUpdate still takes ~22.2ms with 5000 units. My guess right now is division/remainder calculations taking up processing time.
Add RTSFormationDestroyer for handling entity destructtion (still needs testing)
Fix destroyed entity not being properly filled in
@Ji-Rath
Copy link
Contributor Author

Ji-Rath commented Jul 11, 2022

I finally tackled performance and gave into using arrays for formations.

With 5000 entities
Before

  • RTSFormationInitializer - 100.1 ms
  • RTSFormationUpdate 10 s

After

  • RTSFormationInitializer - 378 μs
  • RTSFormationUpdate - 22.2 ms

Kind of embarrassing looking at the original stats but still progress! I have ideas to make the update faster (currently only runs when an entity needs a new position), but I think it is 'good enough' for now.

MassSample-FasterFormations.mp4

@Ji-Rath
Copy link
Contributor Author

Ji-Rath commented Jul 14, 2022

Multiple unit support! Units now automatically rotate when moving to a new position too.
I'm thinking about wrapping it up soon, so any suggestions are greatly appreciated. To be honest, this isn't groundbreaking work but maybe this example will inspire someone to create a better real-time 'Total War' game lol.

MassSample-FormationV1.mp4

My only gripe is that this plugin depends on the MassCommunitySample plugin too. This is so entities can be destroyed with the sample projectile. One solution would be to either remove the functionality or implement it maybe in the project/plugin?

Oh and these too lol

  • Optimize Signal calls
  • Find solution to entities not moving in formation (while in route to destination)
  • Move center point to 'front-center'
  • Add option to change formation length for individual units

@Ji-Rath Ji-Rath marked this pull request as ready for review July 14, 2022 15:35
Ji-Rath added 2 commits July 14, 2022 10:37
Sorry this is a little messy, I just have a new idea for MassSample and should have created a new branch in my fork first
@Ji-Rath
Copy link
Contributor Author

Ji-Rath commented Jul 14, 2022

This is gonna be just a little messy, I made the mistake of creating this plugin in main, so Im just going to create a new PR with the new branch so I can do some more work

@Ji-Rath Ji-Rath closed this Jul 14, 2022
@Ji-Rath Ji-Rath mentioned this pull request Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants