Read: Tables for Enemies in Tower Defense

Hello! I just bought a TD template. The template (which I do not want to mention) seems to be using tables for calculating enemy positions. This is good since then the towers, which are spawned when bought from the side menu, can target specific enemies to shoot and though they share the same radius actor, do not shoot at the same target. However, the problem is:

IT LAGS SO MUCH ON MOBILE

There are numerous tower defenses done already with Gamesalad, but I've spent the last week trying to figure out an alternative to this problem. I know this has been posted so much already but...

How do I make it so that the second tower (same actor as first) doesnt shoot when the enemy is inside the first tower's range? Are there alternatives to the table solutions? I'm really bummed about this.

Comments

  • ArmellineArmelline Member, PRO Posts: 5,354

    I've never seen anyone come up with a really viable tower defense system in GameSalad. A few have come up with some clever solutions, but I've never seen anyone crack the problem. Including the paid templates.

    I think you're treading new ground if you solve this. First thing to ask, though, is how are the locations of the enemies being tracked? You need to know how far each enemy is from each tower. First thing I'd try would be to have each tower's position be placed in a table, and have each enemy constantly checking this table and comparing these positions to their own position. If the enemy finds itself in range of a tower, it places itself in a table column dedicated to a particular tower. The tower checks the table column and any time it finds something in it, it shoots at that location.

    This is just vague speculation, though - I've never put any real thought or effort into solving this problem.

  • dariusimmanuelguerrerodariusimmanuelguerrero Member, PRO Posts: 19
    edited April 2017

    @Armelline, thank you for your reply.

    Each enemy is a column ina table. The x and y are the two rows. Let's say there are ten enemies.

    Sample logic:

    Each tower has the logic that if tower's distance from enemy is less than tower's radius, and if tower's distance to enemy 2 is less than distance to all other enemies, then set (what enemy to shoot attribute to 2.

    and you make 9 more of that. and duplicate it to all actors. it actually works! but the processing power, the tables updating every 0.1 seconds.. it's just laggy

Sign In or Register to comment.