Physical projectiles - struggling to understand

JohnG

Member
Hi Justin or experienced ucc users,

I am trying to setup a projectile, however am struggling to understand it via testing (trial and error), and get the balance of the settings correct.

My main question is:

  1. What are the recommended settings for a projectile so that it behave as closely to a real projectile, and still registers collisions accurately?
  2. I assume ucc can not replicate real life bullets and speed, is this correct? I assume this, as the actual size and speed of the bullet is going to be too small and quick to work with colliders.

here is my setup so far (which doesn't work).
  1. The actual projectile is a simple unity 3d sphere. As per the projectile slot on the weapon (assault rifle), I need to add projectile script to sphere (projectile), which adds a rigidbody. I change coll detection to continuous speculative, the rest I leave as is.
  2. I change the sphere scale to 0.1f.
  3. For the projectile script, I change the speed to 1000 and mass to .1
  4. I dont need to see the projectile so I turn off mesh renderer.
 
Physic Frames in Unity are fixed, so you always have (don't know the exact amount) 50 physic frames per second.
If your bullet travels so fast, you don't even need a mesh renderer, you could write a custom raycasting system, that calculates for trajectory, wind and whatever your bullet physics need. You control the raycasts and do not need a collider at all.
If raycast doesn't suit your need because bullets have a volume, you could also use a SphereCast instead.

This way you have maximum control over the bullets virtual movement, speed and so on. I did this for a lot of games I made, because at that speed, even if it works - the unity physics-solver (Nvidia Physics) won't provide the most accurate results, you have no control and it is performance heavy to use it, compared to a raycast/spherecast.
 
This thread is a pretty good description of how the trajectory object works. The bow arrow is a better representation towards a real world bullet, but you'll want to increase the speed.

As @Leorid mentioned, using a raycast solution is the way that you want to go. The Trajectory Object uses a raycast (or spherecast) to determine its collisions so from that standpoint you'll correctly detect collisions.
 
Top