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

Started by urielito3010 on Mon, 03/22/2021 - 18:49

Topic category: User side tutorials

Last seen on 03:13, 20. May 2022
Joined Dec 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Adding Spread to Ranged Items (Formula, tutorial, and workspace here) (Shotgun like item)
Mon, 03/22/2021 - 18:49

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