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 Hamesh81 · Jan 07, 2015 at 02:23 PM · projectiletargetaim

How to ensure multiple weapons fire towards the same target?

I have a shooting system that uses projectiles instead of raycasting due to specific game requirements. When firing one weapon it is quite simple to display a reticle for where this weapon's projectile is headed; this is also the case when two of the same weapons are being dual fired since they both have the same effective range. What I can't seem to figure out is how to handle dual wielding different weapons, i.e. weapons that have a different effective range since after leaving their respective weapon barrels, the two projectiles have a different target to aim for, don't they?

Since the weapon system uses projectiles which are physically fired from each barrel (and have a trail clearly showing their firing origin), as far as I understand I cannot simply fire both weapons from the center in a straight line since this would be visually obvious. I am also against the idea of using a separate reticle for each weapon since this is not how dual wielding is commonly handled in modern shooting games. So I am wondering how can weapons of differing effective ranges fire towards the same target so that only one reticle can be used? Should a different target be used for each weapon, or should they both share the same target?

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

1 Reply

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

Answer by Cherno · Jan 07, 2015 at 04:53 PM

I would do it like this:

Cast a ray from the camera forward. Then, for each weapon:

Declare a Vector3 that acts as the gun's aiming point. If the distance between the camera and the raycast's hit.point is bigger than the gun's max range (or if there is no RC hit at all), the aiming point is camera.transform.forward * max range. Else, the aiming point is the hit.point. After you have your aiming point, just rotate the gun so it looks directly at it, using Transform.LookAt or similar. For very close points, you might also want to slide the gun towards the center bottom of the screen.

Comment
Add comment · Show 2 · 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 Hamesh81 · Jan 08, 2015 at 01:43 AM 0
Share

That sounds like a good idea. Since this is a system for a 3rd person game I will have to be careful how much I rotate and move the guns around so that it isn't so obvious from over the character's shoulder etc. I suppose what I could do as well is make all of the bullets/projectiles home in on the center target; even though this would stop the bullets from travelling in a completely straight line, over the range that they will be fired this shouldn't be that noticeable and it should be easier to achieve precision this way.

avatar image Cherno · Jan 08, 2015 at 03:18 PM 0
Share

For third person, maybe casting the ray from the model's head (using the head bone as the origin, for example) will be better than from the camera. As for rotating the guns, since 3rd person view uses no dedicated view models, you will probably achieve the best results with a simple I$$anonymous$$ solution so your guns and the arms and hands holding them follow the target position.

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

26 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

Related Questions

Aiming in the direction of cursor in third person. 2 Answers

Enemy Aims at Player's Current Position 1 Answer

Shoot bullet and control its speed 1 Answer

fire towards mouse pointer 1 Answer

target tracking with lead time 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