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 /
avatar image
0
Question by notijaz · Jul 28, 2018 at 04:14 PM · hitarrowcalculate

how to calculate where an arrow will hit the enemy

I want to calculate where an arrow will hit the enemy before it actually hit him ,if it,s a headshot then the slow motion stuff. I,m not new to unity, i have done everything i could( raycast and projectile, search Google...) but it doesn't seem to work. So please please help!

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 Captain_Pineapple · Jul 28, 2018 at 04:55 PM 0
Share

Hey there,

you should probably split your problem in 2 seperate problems:

1: calculate where your arrow will be in "N" frames. 2: calculate where your enemys will be in N frames.

the First problem is a lot easier to solve than the second. If you want to i can write you some calculations and speudo-code for this if you provide me with some more info how your arrows are handled (e.g. do you use physics or a raycast for your arrows, speed etc) Especially the speed is interesting since the faster your arrow is your problem is far more easy to solve.

the second problem is a bit more difficult. How do you move enemys/targets? Nav agents? Do you have a "$$anonymous$$ovementpolicy"? How fast are your targets? How often do you recalculate what your targets are doing? Please put out some more info on this.

avatar image notijaz Captain_Pineapple · Jul 29, 2018 at 06:52 AM 0
Share

Thanks for reply Yeah i want to solve the first problem i can do the 2nd one.physics is use for arrows (rigidbody and forces). Raycast cant be used because the arrow do not travel in a straight line it moves like a mortar(projectile motion) basically in my game enemies are far enough less force is applied on the arrow and the player will have to figure out where he should aim to take a headshot.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cynikal · Jul 28, 2018 at 04:54 PM

https://docs.unity3d.com/ScriptReference/RaycastHit-point.html

That will return the exact point the raycast hit.

You can then do something along the lines of if hit gameobject.name == "head" play slow motion.

(Using psuedo code...but you should know how to convert it)

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 notijaz · Jul 29, 2018 at 06:53 AM 0
Share

There is no raycast in my game

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

89 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

Related Questions

Best way to create Onscreen arrowkeys on gui 0 Answers

Need help when arrow hits collider 1 Answer

Are tag settings passed down from Game Object parent to mesh child? 1 Answer

swing to hit a target 1 Answer

Destroying object using his name and raycast 2 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