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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by krisdamato · Apr 24, 2013 at 02:54 PM · collisionphysicscolliderprojectilebullets

Projectiles, their speed, and collisions

Argh... I've been fooling around with a projectile object and almost got it to work. I've got a projectile that flies out at an (initial) speed of 500m/s. If it hits anything in the air, it will call its OnTriggerEnter() function and if the collider's an enemy agent, it'll deal it some damage.

Alright, it sort of works. Almost because sometimes when the enemy agent is very close the trigger isn't called. That's one problem. I tried to fix that by making the collider large enough (10m at a fixed update of 50Hz), but still, since the trigger functions are called after all physics updates, the projectile will have moved considerably in that time span.

So I reduced the timestep to 100Hz, which kind of helps. Updates are more frequent and most times the enemy's collider is struck. But not all the time. Hmph.

A second problem is that since the collider is so large (and travelling so fast), if the agents are so placed: |Shooter||Victim||Wall|, the collider may actually trigger on the wall, which calls the Destroy() on the projectile without ever calling the damage dealin' function.

A final problem is that the projectile's attached mesh renders right on top of the shooter if I instantiate it as close as possible (which, because of the other two problems, I need to do).

So what are my options here?

Reduce the timestep further? (Doesn't this hog the CPU?)

Have the bullets fly slower? (Wouldn't that be less than realistic? Nevertheless, if that's how it's done, that's how it's done).

Forget this high-speed projectile poppycock and go for raycasting? (Same as above).

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 Glister · Apr 24, 2013 at 03:02 PM 0
Share

Just a thought but you could have the projectile start out slightly slower and then speed up.

avatar image krisdamato · Apr 24, 2013 at 03:14 PM 0
Share

Not a bad idea. I was hoping for a cleaner solution though.

1 Reply

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

Answer by krisdamato · Apr 25, 2013 at 09:17 AM

I "fixed" this by raycasting back along the path of the projectile, using the distance it travels in one timestep to determine the length of the ray.

At first I thought it would be too expensive, but then again there's only going to be a handful of projectile at most at the same time. It seems to do the trick.

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 Bunny83 · Apr 25, 2013 at 11:42 AM 0
Share

So you basically reinvented DontGoThroughThings, right? ;)

avatar image krisdamato · Apr 25, 2013 at 10:03 PM 0
Share

Oh, did I? :(

Sure seems like it.

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

13 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

Related Questions

Bullet projectiles with collision info without affecting others 0 Answers

Collision occurring when it should not! Help! 1 Answer

Tossing an object with the correct force at any distance from another so that it collides with the other 1 Answer

How can i create a character like dragon hill game, Digging underground, what collider should i use? 0 Answers

Camera gets flung off of the map when the player collides with certain objects. 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