How to make a beam attack

I would i go about making a hitbox for a beam attack would i use horizontal angle from direction along with the vetical one? and if so what would the ddirection be. I’ve tried raycast damage but its pitpoint damage and very hard to land

There are plenty ways of implementating such types, also here on the forums are some provided, you can search for them if you haven’t already. The first attempt when you want the beam attack to be wider and not pinpoint is to use Closest Player to Rectangle, when the Beam is fired from a Player of course, idk if these Beams should be fired from a Player or are Entities on their own like traps or if they act like barriers to encapsulate certain areas on a map. The second attempt is similiar to creating a projection paralell to the Players screen in the case of a beam in a shape of a circle with a radius which is the width of the beam and cast it out from the Eyes Position of a Player to the direction you are looking, so Facing Direction is involved.

1 Like

I looked on the fourms i cant seem to actually find any?

1 Like

This would be the way to go, since Closest Player To Reticle is unreliable at best for anything else than getting exactly what its name says.

Fortunately, I have solved this and created a demonstration code some time ago:

Though the share code is most likely dead by now.

So here is a new code example for you:

rule("Boom, you looking for this?")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Dummy Bot(Event Player) == False;
		Is Button Held(Event Player, Interact) == True;
	}

	actions
	{
		Create Beam Effect(All Players(All Teams), Good Beam, Eye Position(Event Player) + Vector(0, -0.250, 0), Eye Position(Event Player) + Facing Direction Of(Event Player) * 100, Red, Visible To Position and Radius);
		Event Player.beamID = Last Created Entity;
		While(Is Button Held(Event Player, Interact));
			Event Player.playersInView = Filtered Array(Players in View Angle(Event Player, Team 1, 45), Is Dummy Bot(Current Array Element));
			For Player Variable(Event Player, loopCounter, 0, Count Of(Event Player.playersInView), 1);
				If(Distance Between(Event Player.playersInView[Event Player.loopCounter], Eye Position(Event Player) + Normalize(Facing Direction Of(Event Player)) * Dot Product(Normalize(Facing Direction Of(Event Player)), Event Player.playersInView[Event Player.loopCounter] - Eye Position(Event Player))) <= 2);
					Set Status(Event Player.playersInView[Event Player.loopCounter], Null, Burning, 0.500);
				End;
			End;
			Wait(0.500, Ignore Condition);
		End;
		Destroy Effect(Event Player.beamID);
	}
}
2 Likes

Excactly that, thanks @Shanalotte, this code as reference should also have a place on the workshop.code 's Wiki section for anyone interested in, to check and use it as an example sheet :D.

1 Like