Announcement

Collapse
No announcement yet.

ProjectileMovement Vs Raycasts for Bullet Drop, Penetration, Ricochet

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ProjectileMovement Vs Raycasts for Bullet Drop, Penetration, Ricochet

    I have been thinking about making a shooting range in UE4 some what realistic at least in terms of Ricochet, Bullet Drop and Penetration.

    My first bet is to use Raycast for this As Realistic Bullets are Fast so using Projectile Object might not be the best idea as that might miss collisions or glitch due to frame rates (Correct me if i am Wrong).

    Using Raycast:​​​​​​

    1)As for using Raycast the Idea is to have Smaller Raycasts and if the Hit Result is NULL we can Create another Raycast from the Ending Location of previous one and set its Ending point a bet below to simulate the bullet drop effect. Again I haven't really dived into the Curves of UE4 so if there exists a better solution please do share.

    2)Now for the Penetration using MultiRaycast might be more than enough for this depending on the Physical Material we can add the impacts more Hits Rather than only the first one.

    3)Ricochet or Bounce that might be a bit difficult and I kind of don't really know what to do here. One Option is to Create Another Raycast From the Impact Point to a Random Endpoint but again there is the problem of Right Rotation. Some kind of Reflect Vector.

    I would be posting the Solutions or any progress Here as I Go along any help is great you can share your wisdom.

    Why Not Projectiles:

    So, for Performance Reasons I decided not to use Projectiles I think they are an over kill for Automatic Weapons like Assault Rifles and Machine Guns better to have Hundreds of Raycasts than a fully simulated physics object bouncing around your scene.

    Now I may be a bit harsh on Projectile Component but honestly I don't know much about it, you can help me decide.


    #2
    OK, you are wrong. Bullets don't *EVER* travel in straight lines. Laser guns might though, if they existed. Lasers definitely do travel a straight line, and at the time of light.

    1) use math instead? it's probably faster to boot. You have a start point, you have gravity. you can estimate the speed. the rest is math.

    2) what? why would you add more hits? that's confusing. do you mean continuing on after the first hit? sort of the same as 3.

    3) that's already an option with ray tracing, basically you can detect the Normal of the item you hit, and decide via math at what angle the bullet should ricochet. there's precise formulas for this depending obviously on velocity, spin, composition of the bullet (FMJ, vs led) hardness of the material, etc.


    Don't even mention "Somewhat realistic" if you aren't using projectiles of some sort (you could make your own component with your own mathematical formulas). And USUALLY, projectiles don't impact performance for their lifespan is too short to do so. (normally you remove them after impact or shortly after in the case of a ricochet Any decent tutorial will show you how to get them to destroy, any tutorial that doesn't should be automatically not watched).
    In other words, unless you have 100 players all contemporaneously shooting into a badly made MMO you have no chance of getting hundreds of projectiles lingering around long enough to cause performance issues, even with way more intense calculations happening then the projectile component calls for, and crazy Cascade/Niagara particle effects within the projectile....

    Comment


      #3
      Originally posted by MostHost LA View Post
      OK, you are wrong. Bullets don't *EVER* travel in straight lines. Laser guns might though, if they existed. Lasers definitely do travel a straight line, and at the time of light.
      I wasn't talking about a single Raycast and i managed to do it and it works perfectly.
      here is the result.


      Now the Question is, is it worth the effort or I should simply use Projectile Movement Component ?
      Last edited by HarisCuman; 12-07-2019, 03:30 PM.

      Comment


        #4
        It's pre-done with all the math you need... I think it even takes bullet weight into account for the flight.

        If you want to go through the math, it's definitely good exercise. The most likely place to find accurate math is army related stuff.

        Comment


          #5


          Was a good Exercise learnt a lot of new things. All this is based upon simple raycasts everything is calculated and kept up to date all the way from Bullet Spawning to its Stopping.

          Comment


            #6
            Are you taking into account some physmat parameters?
            if you wanted to go the extra step that's where you should look into.

            maybe even create some accurate physical materials parameters for bullet penetration.

            physmat is the hard way. The easy way would be to make a couple of tags and assign them for changing penetration values/stopping power.

            Comment


              #7
              Yeah i am going for the PhysMaterials and their Density.

              Comment

              Working...
              X