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

Started by Kleiders on

Topic category: User side tutorials

Active 1 month ago
Joined Dec 2016
Points:
939

User statistics:

  • Modifications: 2
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 3
  • Comments: 124
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

Active 1 week ago
Joined Feb 2023
Points:
271

User statistics:

  • Modifications: 0
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 106
Thank you!!
Fri, 07/05/2024 - 21:10

Thank you!!