Announcement

Collapse
No announcement yet.

How do I create a scatter FPS bullet mechanic

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

    How do I create a scatter FPS bullet mechanic

    Hello, does anybody know if there's a tutorial somewhere where I can learn how to blueprint scattering bullets, something similar to hanzo's ability in Overwatch but with a bullet instead ()
    Thanks to anybody who decided to dedicate a few words to reply

    #2
    I know nothing about Hanzo but the most basic implementation would look something like this:



    Click image for larger version

Name:	Annotation-20191110-124258.png
Views:	44
Size:	124.2 KB
ID:	1685035

    Click image for larger version

Name:	Annotation-20191110-124234.png
Views:	40
Size:	364.8 KB
ID:	1685036

    Comment


      #3
      Originally posted by Everynone View Post
      I know nothing about Hanzo but the most basic implementation would look something like this:



      Click image for larger version

Name:	Annotation-20191110-124258.png
Views:	44
Size:	124.2 KB
ID:	1685035

      Click image for larger version

Name:	Annotation-20191110-124234.png
Views:	40
Size:	364.8 KB
ID:	1685036
      I was thinking more like shooting a single bullet that on contact with say a wall would split in different directions, from what I see on the pictures on your post, the scatter would start from the barrel, right?

      Comment


        #4
        Originally posted by AbderrahimJami View Post

        I was thinking more like shooting a single bullet that on contact with say a wall would split in different directions, from what I see on the pictures on your post, the scatter would start from the barrel, right?
        Yeah, my Hanzo knowledge is lacking. Like this then perhaps:

        Click image for larger version

Name:	Annotation-20191110-131348.png
Views:	46
Size:	195.5 KB
ID:	1685046

        Click image for larger version

Name:	Annotation-20191110-131307.png
Views:	43
Size:	275.1 KB
ID:	1685047

        Comment


          #5
          yep, that's exactly what I meant, thanks man, I appreciate it, I'm kinda wondering how I would go about adding an effect similar to this: https://giphy.com/gifs/TgNvjNhR8tKhiINgUC

          Comment


            #6
            You will want to look deep into Projectile Movement Component.

            The basic setup for this effect would look like this, you'll need Bounce and Initial Speed.

            vid: https://i.gyazo.com/fc016f7ab34fa952...5f4a38cfee.mp4

            Click image for larger version

Name:	Annotation-20191110-161408.png
Views:	52
Size:	150.7 KB
ID:	1685096

            There's no physics simulation on the sphere. In the Construction Script of the projectile you set the velocity which is actually interpreted as direction by the above-mentioned component providing there's a value greater than zero set as Initial Speed (see above). This makes it fly off in a completely random direction (which ideally should be improved with some surface normals math)

            Click image for larger version

Name:	Annotation-20191110-162035.png
Views:	40
Size:	52.1 KB
ID:	1685097

            The spawning is pretty much the same:

            Click image for larger version

Name:	Annotation-20191110-162354.png
Views:	42
Size:	202.5 KB
ID:	1685098

            The trails are done here with debug points just to visualise trajectory - look into particle - ribbon (?) I think, to do it right.

            Hope this gets you started.

            Comment


              #7
              Thanks, man, you've been more than helpful, really, I appreciate you dedicating time to explain this to a complete beginner

              Comment


                #8
                I sort of implemented the scatter bullet in my demo, but now the bullets (spheres rather) are not really traveling on a straight line, if you look at the gif, after the first hit the bullets go straight in different directions, my spheres just fall on to the floor, I unchecked the simulate physics box on the sphere component but it didn't fix anything. At the moment the direction of the sphere is set randomly, but I'm trying to come up with a more realistic approach, since sometimes when I shoot a wall some spheres go through it instead of bouncing off, in my demo I also have ricochet bullets, for those I'm using a mirror vector by normal node, but it just returns a direction vector, I'd need multiple mirror vectors but with a different direction for every bullet.
                I made a video to show you what I mean https://imgur.com/a/jKj3Sea

                Comment


                  #9
                  Looks like you forgot to set the Projectile Gravity Scale to 0. As in the image I posted, at the very bottom here:

                  Click image for larger version  Name:	Annotation-20191111-153139.png Views:	0 Size:	26.4 KB ID:	1685544

                  At the moment the direction of the sphere is set randomly, but I'm trying to come up with a more realistic approach, since sometimes when I shoot a wall some spheres go through it instead of bouncing off,
                  That's what I originally meant by improving the normals. You'd need to take the normal of the hit surface and have the projectiles spawn in a cone pointed along that normal. At the moment it's a sphere so they do go everywhere indeed.

                  edit:

                  So this should work nicely:

                  Click image for larger version  Name:	Annotation-20191111-154410.png Views:	0 Size:	99.0 KB ID:	1685556

                  You can get the extra New Direction pin on the spawn mode by modifying the Construction Script in the projectile like so:

                  Click image for larger version  Name:	Annotation-20191111-153915.png Views:	0 Size:	77.7 KB ID:	1685557

                  It's a new vector variable that gets updated when the projectile spawns.

                  In addition, ensure that sphere's collision ignores other spheres - since they all spawn in the same spot, they will bounce off each other initially a lot and lose momentum - this can be further refined by using custom collision channel if necessary, but ignoring Physics Body should do the trick:

                  Click image for larger version  Name:	Annotation-20191111-154509.png Views:	0 Size:	50.5 KB ID:	1685558

                  Should work a wee bit better now:

                  https://i.gyazo.com/ac56f30caa988ae6...e57ca7eb4f.mp4

                  To make it work even better, you could also account for the firing direction so the projectiles ricochet in a cone rather than just shoot out from the surface in a perpendicular fashion. Not sure how realistic it's supposed to be, though.

                  edit2: yeah, combining a mirrored vector with a bit of random scatter should get you there. Or like this:

                  Click image for larger version

Name:	Annotation-20191111-160156.png
Views:	22
Size:	103.5 KB
ID:	1685569
                  Last edited by Everynone; 11-11-2019, 12:02 PM.

                  Comment


                    #10
                    Oh my god, it does work, apparently I'm an idiot, I didn't check the gravity scale, thanks for explaining the projectile spawning, since we're ignoring the physics body on the sphere though, they're not colliding with the rest of the geometry on the scene now.

                    Comment


                      #11
                      they're not colliding with the rest of the geometry on the scene now.
                      Is your entire scene physics based?

                      Comment


                        #12
                        I can see in you're gifs that the spheres are actually colliding with the rest of the geometry, how did you do that? may I ask?

                        Comment


                          #13
                          Originally posted by Everynone View Post

                          Is your entire scene physics based?
                          the project is just the default FPS demo, apart for tinkering with the firstpersonCharacter blueprint I haven't really touched anything

                          Comment


                            #14
                            I think that some of the boxes in that scene are physics based, they can be pushed around if I remember correctly.

                            There is something called Object Channels and one can set up their own. Once you set them up, they show up as tickboxes in the physics settings (of the static meshes, like the sphere). They can be set up here, at the bottom:

                            Click image for larger version  Name:	Annotation-20191111-165932.png Views:	0 Size:	127.5 KB ID:	1685610

                            I may not have time to look into this today or tomorrow but here's a really good read:

                            https://forums.unrealengine.com/unre...sion-filtering

                            Do tell if you make progress!
                            Last edited by Everynone; 11-11-2019, 01:19 PM. Reason: typos

                            Comment


                              #15
                              Thanks man I'll look into it right now

                              Comment

                              Working...
                              X