Search Unity

Turret

Discussion in 'FPS.Sample Game' started by DoctorTaco, Jan 7, 2020.

  1. DoctorTaco

    DoctorTaco

    Joined:
    Dec 16, 2018
    Posts:
    1
    Hey!

    Trying to make a turret that fires on its own. I've seen other posts about making custom weapons, but for now the Terraformer's will fill my needs. I just need to get it to, well, fire, and I'm not sure how. For now shooting constantly is fine, I can work out "when to shoot" logic later.

    I've looked at the GameLoop, and I see where it gets the primary fire input from the user. But I don't see where it actually uses the ability, or makes the request to create a projectile.

    In short,
    Broadly - How do I make a turret that fires on its own?
    Specifically - Is giving the turret the AutoRifle ability a good approach? If so, how do I do that?

    Thanks!
     
  2. AggressiveMastery

    AggressiveMastery

    Joined:
    Nov 19, 2018
    Posts:
    206
    Howdy Doctor Taco :D

    Check out the DebugMove, it is a subscript that sends commands as a player.

    Also check out the Exploding Barrels, and how they do damage, you could spawn a barrel near a player that is supposed to receive damage, and have that render the damage. Or shoot the barrel at them, lol.

    Overall, I would recommend looking at Code Monkey's Youtube serries on DOTS/ECS and writing a jobs/DOTs/ECS turret AI, and use that on the server only, to control a turrent as the turret's AI.

    But- offloading that work to a client, aka the debug move approach, could provide even better performance. Turret AI on a client, sending results to the server, to then replicate out to the other clients.

    The next sample, the DOTS sample, which is now out, has a 'turret' in one of its levels. But I have not loaded that up yet, or gotten it to work. But you may want to check that sample out as well.

    https://github.com/Unity-Technologies/DOTSSample

    Good Luck
    Micah
     
    Stexe likes this.