Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by tet2brick · Aug 21, 2012 at 03:13 PM · mathspaceshooteraimtargeting

3D spaceshooter : targeting system

Hi guys,

On many 3D spacheshooters there is a marker in front of the ship you are trying to shoot, like in freelancer (the red cross):

alt text

It's the point you need to aim to have the most chance of hiting the ship (if it don't change his trajectory) calculated with the direction of the ship, its speed, and the speed of the bullet. (I suppose)

I understand the principle (I suppose. Again. :p ) But I have no idea what the exact mathematical formula is.

Can you help me?

Thanks a lot :)

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by gegc · Aug 21, 2012 at 03:51 PM

Ah, the target tracking problem. Here you go.

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 TalG · Mar 25, 2015 at 03:48 PM 0
Share

amazing code!!! and is well explained!

avatar image
0

Answer by tet2brick · Aug 22, 2012 at 09:23 AM

Thanks a lot, I will read that :)

Comment
Add comment · 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
0

Answer by tet2brick · Aug 23, 2012 at 09:11 AM

Hi again

I've managed to put that in place as I wanted, so first of all, thank you sir. :)

But there is two small problems.

To calculate the "Aim point" I need to put a rigidbody on the target ship, the bullet and the shooter. So I need to move them by adding forces (so the object can have a rigidbody.velocity value)

The first problem is that when the bullets collide with the target ship, the ship goes spinning maddly, even if I use a highest mass for the ship.

The other problem is that I find it more difficult to move the ship with the engine physics than with a simple transform.position or transform.translate. Is there a simple set of functions to move object with the physic engine OR is it possible to adapt the class you gave me to use it with function like translate?

I've tried to calculate a velocity based on the current and last position, but even with time.deltatime, but the numbers returned change a lot each frame so the visor is jittering maddly.

Thanks again :)

Comment
Add comment · 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

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

9 People are following this question.

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

Related Questions

How can i change the player controls in Space Shooter to Touch. 1 Answer

3rd person cross hair that is oriented to character, not center screen. 0 Answers

"AI"/Behaviour for a Waypoint system 1 Answer

I desparately need a space skybox 3 Answers

Performance view over spawn waves method 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