Issue with projectiles

Frosty Toast

Terrarian
I've been working on learning some of the basics for coding in mods, and I have successfully been able to spawn a projectile and have it do damage. However, this projectile does not move or shoot when I swing the sword; it merely sits stationary.

Any insights on things on things I can add or code I can tweak?

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace ExampleMod.Projectiles
{

public class BeetleShot : ModProjectile
{
public override void SetDefaults()
{
projectile.damage = 500;
projectile.width = 20;
projectile.height = 28;
projectile.friendly = true;
projectile.melee = true;
projectile.tileCollide = true;
projectile.penetrate = 2;
projectile.timeLeft = 200;
projectile.light = 0.75f;
projectile.extraUpdates = 1;
projectile.ignoreWater = true;
}
public override void AI()
{
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f;
}
}
}
 

Kazzymodus

Moderator
Staff member
Moderator
It's not moving because you're not telling it to. ;)

Your AI method only sets the rotation of the projectile. If you want your projectile to move, you need to set projectile.velocity to some value.
 

Frosty Toast

Terrarian
It's not moving because you're not telling it to. ;)

Your AI method only sets the rotation of the projectile. If you want your projectile to move, you need to set projectile.velocity to some value.
1604665894627.png

Can't believe I didn't think about that.
Thanks :D
 
Top Bottom