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 rodriafz · Jun 22, 2021 at 02:45 AM · raycastpredictionrotatearoundpivot

Block Incoming Projectiles Using Rotation (Video Included)

Video

Hello,

I've been trying to find a way to accomplish this now for a while, but it seems like my solution isn't nearly as accurate and trustworthy as the example in the video.

As you can see in the video, the two "pods" seem to rotate around a fixed point (the middle of the player's ship) and block incoming projectiles.

I tried to replicate this by making my two pods children, and having their parent rotate itself. This way, the positions of the pods maintain the same distance away from each other and rotate in sync like in the video.

However, I am unsure how the developers of Varth managed to calculate where the pods need to rotate to. I've tried using raycasts that are drawn from the bullets closest to the player. Any ray that collides with the player lets me know that I need to begin rotating my pods. Then, I would stop rotating the pods until one of the pods collided with the raycast from the bullet.

This works only half the time though. If you look closely, you can see that the pods in the video seem to rotate back to their original position, on the side of the playership. My guess is that they do this when there aren't any projectiles that pose an immediate threat to the player.

However, when I tried to implement this behavior myself, it doesn't function as cleanly as the one in Varth does. My current solution maybe blocks the first bullet that comes my way, and sometimes blocks others if there is enough time for my pods to "reset" back to their original position. But, as you can see in the video, the pods stay in the same spot if there are multiple bullets close together in a straight line.

I am really unsure as to how they accomplished this. I don't know if their solution is very simple or complex. As of right now, I am unsure if using raycasts is the way to go. I have thought about calculating the time it will take for a certain bullet to reach my player, and determining a good position for my pods to rotate to, but I feel like this may be too expensive a calculation since there are many bullets on screen. Especially considering the fact that to get a decently accurate estimation of where a certain bullet will be at a certain point in time most likely requires a few iterations.

Also, you can see that the pods attempt to block bullets that pose greater danger, so I thought of using a priority queue, where the head is the closest bullet. However, this doesn't seem like a great solution either because both the player and enemy projectiles are constantly moving. Thus, distances are changing, meaning I would have to reconstruct the queue over and over.

I suppose I am asking what you think is the "best" way to accomplish this feature. I know that the blocking mechanic involves the bullets closest to the player, but I am not sure how they accomplished it. Thank you.

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

0 Replies

· Add your reply
  • Sort: 

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

168 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

Related Questions

Collide prediction 0 Answers

Ray is shot in wrong axis 1 Answer

Getting a character to fly(follow cursor in 2D) in Unity4.3 0 Answers

How to add platform motion to player controller without parenting? - Mostly working code 1 Answer

Raycast: Different results depending on distance 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