Adding Spread to Ranged Items (Formula, tutorial, and workspace here) (Shotgun like item)

Started by Kleiders on

Topic category: User side tutorials

Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Adding Spread to Ranged Items (Formula, tutorial, and workspace here) (Shotgun like item)

Workspace with this: https://drive.google.com/file/d/12w2ebmILVR3N-ynQoYG4wUgDAHpRm2Zf/view?…

Video tutorial: https://youtu.be/1e9U_fhODsE

Basically, you can add spread to custom projectiles in ranged items.

This is done by changing the code, but I believe it should be possible for anyone who knows how to make plugins/for mcreator developers to add this as a base option.

If you check the video, you can see that by editing this line:         entityarrow.shoot(entity.getLookVec().x, entity.getLookVec().y, entity.getLookVec().z, power * 2, 0);

You can change the spread of it.
The idea is that you would have a spread in your weapon that you can edit (It can be basic and apply to all, or there could be one for each XYZ)

The formula is: SPREAD = (Number)

(entity.getLookVec().x + (Math.random() * (Number * 2)) - Number)

Example: SPREAD = 0.2

(entity.getLookVec().x + (Math.random() * 0.4) - 0.2)

In this case I made the example with X, but it can work with X Y and Z