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 Essential · May 06, 2012 at 01:59 AM · bullets

Best method for creating bullets

I've been researching this for a couple of days but can't seem to find the best solution for my needs…

Basically I want bullets to act like seen in this video: http://www.youtube.com/watch?v=smdQE8OI2cE

It looks quite simply like the bullets are being instantiated and colliding with the objects in the scene.

However, most of the advice I've seen on the subject says to avoid doing that and to use raycasting. But if I used raycasting, wouldn't I need to instantiate the bullets anyway in order to see them?

Maybe raycasting is wrong for what I'm after?

A kick in the right direction would be appreciated.

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

2 Replies

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

Answer by Essential · May 06, 2012 at 02:37 AM

If anyone else gets curious, I've determined that instantiating bullets is not a bad approach for a game with bullets you can see. It's for games like first person shooters where the bullets move at realistic speeds where raycasting is necessary.

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 CHPedersen · May 06, 2012 at 02:52 AM 0
Share

I think you're perfectly right about that. :)

avatar image Bunny83 · May 06, 2012 at 03:29 AM 1
Share

It depends on the bullet speed. If it's quite slow, just use collisions. If they move at high speeds you need to use raycasting.

Just to clarify: The way of detecting a collision and the way it is visualized are two things.

Just as hint: On mobile devices instantiating and destroying is quite heavy and should be avoided. Usually you would use object pools and just deactivate the objects ins$$anonymous$$d of destroying them. So if you shoot a new bullet you would use an old deactivated. This avoids memory allocation and garbage collection.

avatar image
0

Answer by bnackus · Jan 05, 2017 at 01:15 PM

well, i can tell you the method ive found to work best for me.

the reason you don't want to do collision detection for bullets is because its unreliable. depending on how the bullets move, and other factors, you can end up in a situation where the bullets do not detect thier collision, and seem to just pass through what you are shooting at. this is undesirable as a game designer and as a player, because you can miss shots. to solve this you can do raycasting, but theres also downsides for that too. for one you can't see your bullet, and another is the raycast is done instantaneously so you can't factor in things like bullet speed and drop.

so my solution is to put a raycast on the bullet. the direction of the raycast is the velocity of the bullet, and the distance of the raycast is the distance the bullet moves per frame. if the raycast is hit, it calculates the damage. this way the bullet can still move in accordance with your games physics, you can still see it move around, and you still get the precision of raycasting.

anyway, thats what i do. i hope you find something that works for you :)

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 dev01 · Feb 03, 2019 at 03:52 PM 0
Share

Do you have a script for this?

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

6 People are following this question.

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

Related Questions

colliding bullets 2 Answers

Instantiating Weirdly 1 Answer

Multiplayer FPS Bullets: should they be rigid bodies or raycast? 1 Answer

Make a bullet know who fired it 1 Answer

Destroying Projectile Prefabs after Time 3 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