How to make charge beam

Started by WoLfPlaysStuff on

Topic category: Advanced modding

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make charge beam

Im trying to make a keybind that whenever you press it it shoots a beam of particles that goes on until you let go of the keybind, it damages entities as well. If anyone has made this before and is okay with sending a the file please do. 

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Haven't personally made…
Mon, 01/29/2024 - 23:45

Haven't personally made something like this, but I kind of get the idea. It's gonna involve math though. You need two player-lifetime variables, (a logic variable to determine whether or not they're holding down the beam, and a number variable that counts upwards whenever the logic variable is true.) And of course a keybind to toggle the logic variable when the key is pressed/released.

The beam is the tricky part. You can use the player's look angle vectors to summon particles on or within a radius of the resulting vector, (You would spawn particles at the players x/y/z position plus their x/y/z look angle vectors, multiplying the vectors at increments of 0.2 or so to get a line of particles.) You'd then have to do the math to determine whether any nearby entities are in the path of the beam, which is where my expertise ends- it's possible, (endermen use a similar mechanic), but I'm not sure how you'd do it.