• 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 NMS_TomiBary · Sep 28, 2017 at 07:16 PM · trajectorypenetrationballistic

Ballistic System (Battlefield series)

Hello

I want to make ballistic system with bullet drops, penetrations a ricochets like is in Battlefield 3 / 4 / 1. here is sample from YT: https://www.youtube.com/watch?v=WesY2_cj2NM&t=13s

I have an idea what should i calculate when i want to do ricochets and penetrations.

But idk how to start with raycasts and bullet drops. If i should use FixedUpdate and every frame use raycast and continue adding new raycast from previous end...

Please give me some advice, how should i do that. I am new in Unity and i would like to learn how to do that. And sorry for my English. I'm not exactly the best in it. :D

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
2
Best Answer

Answer by JonPQ · Sep 28, 2017 at 09:26 PM

I've done similar systems.. hunting game, including slow mo, wind, penetration, internal targets etc.... So... you need to ensure your bullet and collision code all works on time deltas. FixedUpdate or regular Update is fine, so long as it uses delta time... have a bullet speed, generate the inital movement vector when bullet is fired.... (moveDirection = the muzzle 'forward' vector, normalized) Then each frame... the bullet will move by moveDirection X bulletSpeed X timeDelta . ...also add in gravity vector each frame to the moveDirection . moveDirection += GravityVector* timeDelta.
also you can do the same with wind if you like .... just a small wind push vector to add in. remember to re-Normalize the moveDirection vector, each frame after altering it with gravity and wind. Then take that move vector, and the distance its going to move for that frame update, and do a raycast with it.... make sure the ray is the length it is going to move that frame, from current bullet position. raycast forward to see if it hits anything.... then if it does... do a raycast backwards to see if it comes out the back of the thing it hit. (if it does, you can add exit vfx there also) Determine if it can penetrate objects or not, using tags, or layers. (probably tags) or if its a critical hit area from tags also. can also add deflection info in the tag name if you like... Non penetrating surface can be hard or soft... hard will bounce bullet at low angles... soft will absorb bullet always.
Penetrating surfaces... you can choose if they deflect the moveDirection vector, and by how much (add a random x,y,z vector into movement vector, and re-normalize (just like with wind and gravity) If you want to get fancy.. you can also add in a factor for drag, to slow down the bullet as it travels. You can also try stuff like reducing bullet speed after a penetration... or only allowing N penetrations, then bounce. If you are gonna do slo-mo... have 2 bullet models... clean bullet, and damaged bullet (for after an impact)

Comment
Add comment · Show 3 · 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 NMS_TomiBary · Sep 29, 2017 at 11:53 AM 0
Share

Okey, thank you very much. I think i will ask you one more time, when something will go wrong.

avatar image JonPQ NMS_TomiBary · Sep 29, 2017 at 05:19 PM 0
Share

heh, you are welcome.. its a fair amount to consider... but super fun once you get it working... especially with slo-mo :)

avatar image Bunny83 NMS_TomiBary · Sep 29, 2017 at 05:36 PM 0
Share

If you have more detailed / specific questions, please ask them as seperate questions.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

70 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

Related Questions

Interpolated Projectile in vertical arc and horizontal (blendable) 1 Answer

Moving the player in a ballistic trajectory in 3D 0 Answers

Basic projectile trajectory with transform 1 Answer

Mathematicians wanted = trajectory target hitting question 2 Answers

projection/trajectory motion Unity3d 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges