### Search in Sort by:

 Everything Blueprint Scripting Current Space

### Search help

• Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
• You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
• cat dog --matches anything with cat,dog or both
• cat +dog --searches for cat +dog where dog is a mandatory term
• cat -dog -- searches for cat excluding any result containing dog
• [cats] —will restrict your search to results with topic named "cats"
• [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

# How to make a shotgun spread

 0 It sounds to me like you're problem is that you're spread calculation is incorrect. What you should look at doing is getting the 'forward' direction of the gun barrel (it may not actually be the forward depending on how you're setup, so substitute with whatever works - may be camera direction). You should also know the point at which all the pellets fire from (possibly a socket at the end of the barrel). For a normal, single shot that fires straight you'd just fire from the end of the barrel in the forward direction. The forward vector should be normalised so it describes only the direction out of gun barrel. For a spread shot you'd want to modify that forward vector (again, making sure it's normalised) by rotating it through some degrees in whatever axis you are interested in. You might find this easier to achieve by using the VRandCone method: `````` /** * This is a version of VRandCone that handles "squished" cones, i.e. with different angle limits in the Y and Z axes. * Assumes world Y and Z, although this could be extended to handle arbitrary rotations. */ static CORE_API FVector VRandCone(FVector const& Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad); `````` I assume there is a blueprint node for this too, maybe earch for Random Cone and see what appears (sorry, never done this in blueprints) To actually see what's going wrong I strongly recommend taking advantage of the DrawDebugLine ( Blueprints: https://api.unrealengine.com/INT/BlueprintAPI/Rendering/Debug/DrawDebugLine/index.html or CPP: http://api.unrealengine.com/INT/API/Runtime/Engine/DrawDebugLine/index.html ). You can actually draw a line from the the end of the gun barrel in the expected direction of the pellets so you can visually see if any of your maths is wrong more ▼ answered Jun 02 '18 at 09:12 PM phil_me_up 1.5k ● 6 ● 6 ● 12 Cultusfit Jun 02 '18 at 10:43 PM Wow...I didnt even realize how messy I had gotten here just trying so hard to get it to work with changes/moves. Trying your debug command. As it turns out i have to change y rather than z. I now have a nice fan of purple lines fireing from the shot gun. I had presumed as it was using the barrel scene component that I would just get it's world location/transformation and alter it the same way I would in the viewport for the mesh to change the direction (that's even how I chose my numbers by changing the z value of the scene component until it was at the angle i desired. Problem I'm having now its it always fires "down". That is at least a bit more manageable. Although I dont really understand why getting the world location/transformation/rotation of a component doesnt get it's rotation.... If you happen to be able to explain to me why i change y instead of z I would appreciate it. Not understanding WHY i will probably make similar mistakes all along the way. And if you have any idea how to make it point in the direction of the object who's rotation it is getting.... Okay....doing the same thing with the pellets...it instead actually fires all of them in the appropriate direction but they fire from points to left and right of the pawn...basically a WALL of bullets rather than a cone. Changing Z they fire from the barrel and a column above it. So neither of those work to to set the rotation....but it has a transformation input rather than a vector input. I figure trying to break it into a vector and change it then put back in is causing the problems 9ysrhpg.jpg (229.8 kB) 9ysrhpg.jpg (200.3 kB) 9ysrhpg.jpg (488.2 kB) Cultusfit Jun 03 '18 at 09:06 AM Alright. Got around to moving the shotgun into a macro. Did a lot of testing. I put a cone in and made sure the object I was using DID rotate after each iteration of the code then, reset to the start position. Did several debug lines Then i made it only move ONE iteration and fire ONE pellet, going through the whole set in 20 shots rather than a single 20 pellet shot. As everything worked out I put a delay in the sequence so that it would wait 0.2 seconds before checking the branch statement again (as seen in the photo). This resulted in every spawn working across every iteration of the "spread" as desired except for the low speed. video here: https://youtu.be/NfTiQLMXD8Y if anyone knows how to make it run at full speed while still spawning every instance I would appreciate it. untitled.jpg (185.6 kB) add new comment (comments are locked) 10|2000 characters needed characters left ▼ Viewable by all users