Love heart
GamePrefabs? Click the button: 

Home > Products > Static (Turret & Tower) A.I.

Static (Turret & Tower) A.I.


Preview demo

Preview

Compatible with: Unity 2.6 and 3.0

The turret and tower A.I. prefab makes it easy to create a shooting object in seconds. This prefab has support for:

  • Projectile attacks (angled rigidbodies)
  • Machine gun attacks (raycasting + fx)
  • Laser effects (raycasting + line renderer)

Here is how to set up a tower or turret:

  • Simply add the TurretAI script to your model
  • Drag effects onto the right slots (like fire effects, projectiles, etc)
  • Set the attack & engage distances
  • Tweak all other variables to your liking (rotation speed, animations, etc)

To make your own effects, simply attach the TurretAIProjectile script to your effects and set the parameters to the settings you are after. Couldn\'t be easier!

All code in this prefab is Javascript. Extra in-editor visibility features are added (like visible firing ranges, etc).

Have fun!

TornadoTwins

Added on September 11, 2010 in Artificial Intelligence

Buy

Indie license 35
Commercial license 65

Please login to buy this product.

What license should I pick?

Comments

log in to comment


Pathkiller

GLitched this too

on October 25, 2010

Tornadotwins

@pathkiller - Not sure I follow what you're saying... let me know what I can help with -TT

on October 25, 2010

Pathkiller

@TornadoTwins for some reason the jump is unlimited leading you to go anywhere you please.... funny i sent a bunch of Youtube PMs and not 1 answer from there

on October 26, 2010

Tornadotwins

@Pathkiller Yes, the movement in the preview demo wasn't made to showcase a realistic character, but it does show that the turrets can aim at any angle. It's merely a showcase, really. Although I understand it may be funny to find out.

As for our youtube channel, 7800 subscribers at the time of writing this. Understandably, we get a LOT of messages (300 a day to be exact). Therefore, we have turned YT notifications off to focus on UnityPrefabs instead. Hope that explains it.

Cheers!

-TT

on October 26, 2010

Grimlock257

Whats the Difference between Indie and Commercial License?

on November 1, 2010

Tornadotwins

@grimlock257 Click the 'what license should I pick' button to get the info you need! http://gameprefabs.com/pages/what_license/

on November 1, 2010

Grimlock257

@Tornadotwins Ok, cool, so i guess these prefabs would fine if i was making a game for my family then, if so Cool

on November 2, 2010

Pixelboi

Will this work on the Unity iphone?

on November 15, 2010

Calebthedesigner

Hey What do i do if iv bought a package such as this one and i lost it while cleaning out my mac?

on December 11, 2010

Tornadotwins

@Pixelboi I haven't tested it in Unity iOS mode, but I don't see why it wouldn't work. No input controls are used for this one (other than the temporary character).

@Calebthedesigner Please contact support for re-downloads.

Cheers!

-TT

on December 14, 2010

Mara5_rivera

how can i make an object break in unity?

on December 11, 2010

Alpboysan

Any way i can make the projectile shoot in a straight line? Ive turned gravity of on the projectile the the turret is angled high and i dont know how to adjust this- thanks

on January 3, 2011

Alpboysan

I found it in case anyone is wondering. You open the turret AI and change the figure 5 to 0 (elevAngle)and it should keep the angle straight

if(isAngledProjectile){
        var g=Physics.gravity.y;
        elevAngle = 0*Mathf.Asin(g*diff.magnitude/projectileSpeedSq); // radians
        if(!float.IsNaN(elevAngle)){

on January 3, 2011

Mcarr1973

Hello Im using Unity 3 but I keep getting this error: Messenger does not contain any Listeners for this message:TurretSeenPlayer UnityEngine.Debug:Log(Object) UPMessenger:Broadcast(String, Object) (at Assets/UPMessenger/UPMessenger.js:84) TurretAI:AcquireTarget() (at Assets/TurretAI/TurretAI.js:222) TurretAI:FixedUpdate() (at Assets/TurretAI/TurretAI.js:134)

Also if I click on the check box (enable it) "Is Angled Projectile" the upper part of the turret rotates but goes off of its base while rotating then looks really bad. How do I correct this?

This is right out of the box I have not modified anything and followed the video to the T. How would I fix these errors and mishaps?

on January 6, 2011

Mcarr1973

Also when you get really close to the turret the upper part of it seems to fall off of its base unti you walk out of that distance anyway to fix this as well? Theres gonna be times when the player runs past the turret or gets close to it.

on January 6, 2011

Mcarr1973

Ok Figured it out :)

on January 11, 2011

Mutantsproducer

@Tornadotwins Is there a point downloading this if it does no damage to the player? I am saying this because I don't have a health bar that lowers on collision with some objects but no others, and a die script. I can't do this because whenever I use your tutorials, I get almost 50 errors.

on January 30, 2011

Mutantsproducer

can someone post a script on making it actually effect you? like you get hit be the laser for 30 seconds and you die.

on February 12, 2011

Msmatis

Is there any way to set up turrets for shooting only in one axis?

on May 4, 2011

Dylan56477

Is this usable with like say a walking character that also has waypoints telling it where to go?

on May 13, 2011

Quakeman00

is it posible to see it someday in c#?

on May 16, 2011

Tornadotwins

To convert JS prefabs to C#, you can use this: http://forum.unity3d.com/threads/46520-Online-UnityScript-Javascript-to-C-converter

on May 17, 2011

Cybershead

@Tornadotwins , ok i have not been playing around with unity for very long, but intend to make a cool game :) Just downloaded your turrets, (Stand by for noob Q) How do you import the Turrets to my library etc please.

Hugz Cybershead

on February 17, 2012

Tornadotwins

@Cybershead You can tell by opening the demo scene. The turrets can be made into prefabs, exported as .unitypackage or you can build your game on top of it. This goes for most of the packages on GamePrefabs.com

-Efraim

on February 17, 2012

Cybershead

@Tornadotwins thank you for getting back to me, i found dragging the asset folder into my project folder did the trick, and i should have looked at the video too, sorry :). All good apart from that it will not let me drab the projectile onto the projectile prefab. Plus if i use the laser, the beam will not die. intact you use a mac and my Unity looks different from yours lol. I really want to get on with unity and create, so it would be great if you could find some time to help.

Thanks

Chris

AKA Cybershead

on February 17, 2012

Armishra

This isnt working on iOS. It worked fine when i published it on Web. For iOS, it throws some errors : "Upmessenger.js" (26,35): Add is not a member of Object. Count is not a member of Object.....

on March 3, 2012