Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by OtreX · Feb 02, 2017 at 12:39 AM · aiturrettargetting

[Help] AI turret's limited range (not your typical turret question)

So, how can I create an AI turret that has a limited range?

Think of the millennium falcon. It has a turret at the top and one at the bottom. The gunner on the top can only shoot to other things that are over the falcon, but as we know... the falcon does all sorts of spins and twirls, so its "over the millennium falcon" but this "over" is relative to the falcon itself.

I tried doing a very low poly half sphere model, then I attached a mesh collider and I placed that as the range of the top turret, but when you do this for many ships the performance drops a lot. Edit: I forgot to mention that I'm doing a OnTriggerEnter with this half sphere mesh collider. //End Edit

Is there anyway in code to tell the top turret to only target ships that are closer than 100 meters, but are higher than said turret BUT relative to the rotation of the falcon?

Thank you

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image HuracanBatman55 · Feb 02, 2017 at 01:27 AM 0
Share

i like ur reference too star wars

avatar image Pengocat · Feb 02, 2017 at 03:35 AM 0
Share

A simple raycast from turret towards current target would suffice? Have a simple collider on the falcon that can obscure the view of the turret.

  1. If raycast hits the falcon the target is "behind" the falcon

  2. else if the target is still not hit (ray is 100m long) then the target has moved out of range

  3. else shoot the target.

...or is your question more related to how you can keep the turret from pointing into the falcon and therefore limit the rotation?

avatar image OtreX · Feb 05, 2017 at 12:31 AM 0
Share

@Pengocat that is indeed what I thought, but there are ships that I just want to limit the angles. Lets say that the top turret of the falcon can shoot at anything that is over the falcon (relative to the falcon). This would create a range of fire in the shape of a half sphere. But now lets say that I want the turret to only fire at anything that is over the falcon and in front of it. This would create a half sphere. Is it possible to limit the angles to get this behavior?

Thank you for your time.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

124 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trouble with a State Machine for Turret 0 Answers

Aron Granberg A*, Set the AI destination setter on a prefab to follow a game object 0 Answers

Turret AI Script - one way detection 0 Answers

How do I make opposing sides in a unity game 0 Answers

Implement Vector3.MoveTowards follow with random movement 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges