tModLoader [Tutorial] Projectile Guide and Implementation: tModLoader Edition

I'm trying to have my laser shoot from the sky straight down on the mouses location but I can't figure it out and I can't find it on the doc.
Making a custom laser projectile is pretty difficult, so you might need to check out the example last prism from exampleMod.
tModLoader/ExampleMod/Content/Projectiles/ExampleLastPrismBeam.cs at 1.4.4 · tModLoader/tModLoader

Firstly, you need to make a sprites sheet for your laser (start, middle, end)
1704313367846.png

In the Item:
Now, you can fetch the Vector2 for the mouse position with Main.MouseWorld in the item's Shoot() method. Offset the position into the sky, add random values, and spawn in the projectiles.

In the Projectile's AI():
Laser projectiles is pretty much the same as normal projectiles. The 2 additions with lasers are overriding PreDraw() and Collision().
You can make a custom collision check for laser by overriding Collision() and return Collision.CheckAABBvLineCollision() instead.
Predraw() is more difficult though as you need to make a custom laser draw method with:
public static void CustomLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
If you are just starting with the modding, I think you should just try other stuff first.
 
With the first post as its very old When I tried both homing projectile ,and orbiting player as I'm very new to coding ,all I really needed to do was change the p in projectile to a capital but In orbiting player code it was showing player.center as red and in homing projectile the hostile in player.hostile shows as red also how to change the speed of the projectile and other factors being able to be modified.
 
Did you realize that.. well I think making projectiles cool requires mathy-type logic. Does this article setup contain how to use Vector2.Lerp with a geometric angle to imitate Super Metroid Wave Beam shots? To be honest, I didn't exactly do this myself, but I saw this was possible in tModLoader.
 
Back
Top Bottom