• 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 /
avatar image
Question by unitydev0008 · Nov 16, 2010 at 04:09 AM · projectiletopdownshootertrajectory

Top down shooter trajectory

Hey guys im currently working on a top down shooter type game where the player is a tank. So far i have the tank turrent rotating around and looking at the mouse position. I am currently trying to get my projectile scripting started and i am drawing blanks at where to start as i am new to programming. What i want is a way to make the projectiles trajectory path set to where it will collide with the ground at the point where the cursor was when the player shot the projectile. So in other words i want the tank projectile to land where the players cursor was when they shot the cannon. Also how would i go about making a min/max range for it aswell so the cannon will not fire right beside the tank. Thanks in advanced for your help and im not asking for anyone to write out all the code for me but jus something to get me started in the right direction!

Comment

People who like this

0 Show 1
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 unitydev0008 · Nov 16, 2010 at 04:11 AM 0
Share

Also forgot to mention the game is always going to be on a flat plane if that is relavent

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Thelo · Nov 16, 2010 at 09:56 AM

There are many possible correct trajectories from a launch point to a target, depending on angle, initial velocity, and whether you choose a high or low trajectory.

For instance, you might choose to always shoot the projectile at the same initial angle, say 45 vertically, and vary the projectile's initial velocity to determine how far it goes. If you want a min / max range for the cannon with that solution, that means you could set a min / max to that initial velocity, or refuse to fire altogether if the target is too close or too far.

Another possibility is to fix the initial velocity, but change the firing vertical angle to determine how far the projectile goes, with 45 going the farthest. With this solution, the "feel" of the projectile leaving the cannon is more constant, since it always leaves at the same speed. Outside of the maximum distance shot (45), there are always two possible angles that will land at the same target - for instance, a 30 shot and a 60 shot, fired at the same initial velocity and without any air resistance, wind, or obstacles, will land at the same spot, but the low angle shot will land faster than the high angle shot will. You can decide to always use the low shot so the projectile lands faster, or use the high shot to better avoid ground-based obstacles, it's up to you.

If you want a min range for the cannon with that solution, you could set min / max shot angles. The max range will be what the range is when firing at 45.

You can find the relevant equations here:

http://en.wikipedia.org/wiki/Range_of_a_projectile

http://en.wikipedia.org/wiki/Trajectory_of_a_projectile

Comment
unitydev0008

People who like this

1 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 unitydev0008 · Nov 16, 2010 at 09:31 PM 0
Share

Thank you tehlo for the very usefull information =D i will look into that asap.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Basic projectile trajectory with transform 1 Answer

How do i make the character look the mouse 0 Answers

How to check if a trajectory is blocked? 1 Answer

Trajectory Projectile with Collision Detection 2 Answers

Trajectory / Projectile in 3D 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