Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

RTS 3d spaceship AI

Discussion in 'Game Design' started by Xhitman, Sep 13, 2016.

  1. Xhitman

    Xhitman

    Joined:
    Oct 30, 2015
    Posts:
    452
    Player can put different turrets on the spaceship body. Every turrets have their own attack range, angle limit.

    The problem is I dont know what is the best direction for a ship to look at enemy, because i dont know how player install turrets. Moreover, because the battle is in 3d, if i make ship transform.forward toward enemy ship transform pivot, all turrets may be out of attack angle.

    So, now i need some idea.
     
  2. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,433
    You'll need to do some math for that. E.g. sample 12 points around the ship at the range of the enemy it is attacking and see which point can be reached by which turret, and add up the damage per second output of the turrets in range and firing arc for that point, then weight the points by which is closer to the enemy you want to attack and then make the ship turn to get that point aligned with the enemy. With some tweaking that should prevent dumb maneuvers like turning the whole ship 180° just to get 10% more DPS output than what turrets are already facing the enemy. You could also calculate the DPS values in a biased-against-the-enemy-type way, that accounts for e.g. unguided rockets being less likely to miss small and fast ships, or lasers being always 100% on target.
    Also if the player has so fine controll to place the turrets, maybe he should be able to manually position the way ships are facing too? They could have varying armor thickness on different sides too etc..
     
  3. Xhitman

    Xhitman

    Joined:
    Oct 30, 2015
    Posts:
    452
    I like your maximize dps idea, I'll think about it, but the math involved seem to be very complicated.

    I can let player define several direction each ship and let the ship use these direction in battle. But the problem is I find it is a mess in the ship editor when I put many turrets. I turn on the attackable space(highlight color mesh) for each turret, I can't tell which direction is good for meeting as front, side etc. So player will face same problem.

    BTW, it will be a 10 vs 10 ships battle.
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    so you'll need to add some helper stuff to the placement of the turrets, either calculations of empty gameobjects or whatever you need to get the fire zones.
     
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I would give this decision over to the player. In sail based naval combat, the orientation of the ship is important. A ship aiming broadside can fire all of its cannons. A ship facing the enemy has only one or two guns that can fire. The main strategy in early naval combat was outmanoeuvring your enemy to bring all of your cannons to bear, while at the same time preventing your enemy from doing the same. I see no reason why this concept couldn't work in space.
     
    Martin_H likes this.