playMaker

Author Topic: Advice for handling Combat  (Read 1256 times)

Athin

  • Full Member
  • ***
  • Posts: 163
Advice for handling Combat
« on: January 27, 2019, 11:35:27 PM »
Hey guys

I'm making a RTS style project with large scale battles and I am looking for some help with the system.  I'm looking to make similar combat like the Total war series and was wondering what was the best way to tackle this?

Currently I'm thinking placing each unit in the squad in an Array.  Using the "leader" unit in each squad Array (Index 0 unit) and compare his distance to each eligible "Enemy" unit.  If he is within X distance then send event to the squad to start combat otherwise keep checking.

I can see this system having some odd results though depending on how wide the formations are set up and what angle each squad comes in at. 

I need something that doesn't require each unit to constantly be active looking for enemies as I'm planning to have quite a few units in play at once

Anyone have any suggestions?

 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Advice for handling Combat
« Reply #1 on: January 28, 2019, 04:02:28 AM »
Hi,

 you can create a mix of triggers that register ennemies within a certain range of your unit, this way you reduce the list of ennemies to go through.

also, for comparison only, prefer using sqr distance, it's faster to compute ( doesn't require heavy math), and it's perfect for sorting ennemies and find the closest, etc.


 Bye,

 Jean

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Advice for handling Combat
« Reply #2 on: January 28, 2019, 06:55:49 PM »
Hey Jean,

What do you mean by Sqr distance?  Is that just simply the Get distance action your talking about or something else? 

I'm trying to avoid trigger boxes as I feel that will get crazy with all the collision boxes on each unit.  I'm looking at around 1,000 units possibly that may be constantly checking so I don't think having a trigger box would be good.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Advice for handling Combat
« Reply #3 on: January 29, 2019, 03:55:33 AM »
Hi,

 yes,  I was talking about another action and realize it wasn't available as is, so I made one, you can get it on the Ecosystem: GetSqrDistance.

1000 units is going to give you a lot more trouble in terms of individual logic than physics triggers. Physics has been optimize to great extends for this, while if you start to manually check distance and sort ennemies, you may end up with a less efficient solution in the end, proper profiling will be required to optimize your algorythm.

Bye,

 Jean

Bye,

 Jean