Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Jun 14, 2018 at 03:06 AM by PanzerPotato for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by PanzerPotato · Jun 05, 2018 at 07:16 PM · physicsaiturretaimingtrajectory

AI Turret Aiming

Hey guys, I'm making a naval game with shore batteries that will fire upon the player. I have looked at other posts and scripts involving target lead and parabolic trajectories, but all I need is a script that allows my turret to aim higher to account for shell drop and lead the target. Any ideas?

Thanks!

ps. My projectiles and targets are rigidbodies.

[EDIT:] I am now intending to fire shells in a parabolic path.

Comment
Add comment · Show 2
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 MT369MT · Jun 05, 2018 at 07:35 PM 0
Share

Hi, sorry for te question but what do you mean with “aim higher to account for shell drops and lead the target”? And is it a 2D or 3D game?

avatar image PanzerPotato MT369MT · Jun 05, 2018 at 07:43 PM 0
Share

Oh, it's a 3D game. The shells will drop by a constant amount per second, and I was wondering if I could have the guns aim higher depending on the shell drop relative to the distance to the target.

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by andrew-lukasik · Jun 05, 2018 at 07:51 PM

 //linear drop:
 aimPosition = targetPosition + Vector.up * distanceToTarget * dropRate;

 //non-linear drop:
 aimPosition = targetPosition + Vector.up * dropCurve.Evaluate( distanceToTarget );
Comment
Add comment · Show 7 · Share
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 PanzerPotato · Jun 05, 2018 at 07:57 PM 0
Share

Thanks, but my shell drop is relative to time, not distance. How could I use this code?

avatar image andrew-lukasik PanzerPotato · Jun 05, 2018 at 08:00 PM 0
Share

rename every "distance*" to "time*"

avatar image PanzerPotato andrew-lukasik · Jun 06, 2018 at 08:29 PM 0
Share

Thanks for the answer, but what is dropCurve?

Show more comments
avatar image andrew-lukasik · Jun 06, 2018 at 11:08 PM 0
Share

Also, this Vector.up, is a direction to compensate gravity alone but you can use arbitrary directions to, for example, compensate for wind blowing etc. Or summarize these and compensate for many such influences.

avatar image PanzerPotato andrew-lukasik · Jun 14, 2018 at 12:27 AM 0
Share

Oh I'm only having drop affect the shell, no other factors like wind. (Sorry for the late reply, was busy with exams)

avatar image
1

Answer by andrew-lukasik · Jun 16, 2018 at 07:03 AM

Check out this repo: https://github.com/IronWarrior/ProjectileShooting/blob/master/Assets/Scripts/ProjectileMath.cs

Comment
Add comment · Show 1 · Share
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 PanzerPotato · Jun 16, 2018 at 01:53 PM 0
Share

I've actually found another similar script which performs extremely well, but this script could be extremely useful to others, and I thank you for that. Thanks for your time! (also maybe move that link into your answer)

Follow this Question

Answers Answers and Comments

193 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 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

Turret Movement 1 Answer

Shell Drop and Aiming 1 Answer

AI rigidboy aiming 0 Answers

Autoaiming Turret Cannon? 3 Answers

Turrets |Aiming don't work 1 Answer


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