My projectile code (so far) looks like this:
public class projectile
{
float rotation;
float rotationAlpha;
Vector3 position;
Vector3 velocity;
float life = 0f;
public void Update()
{
position += velocity * 1000f;
life += .1f;
}
public projectile(Vector3 position, Vector3 velocity, float rotation, float rotationAlpha)
{
this.position = position;
this.velocity = velocity;
this.rotation = rotation;
this.rotationAlpha = rotationAlpha;
this.life = 0f;
}
public void Create(Vector3 position, Vector3 velocity, float rotation, float rotationAlpha)
{
this.position = position;
this.velocity = velocity;
this.rotation = rotation;
this.rotationAlpha = rotationAlpha;
this.life = 0f;
}
public void Render(Model projec, Vector3 cameraPosition, Vector3 camLook, float aspectRatio)
{
Matrix[] transforms = new Matrix[projec.Bones.Count];
projec.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in projec.Meshes)
{
//This is where the mesh orientation is set, as well as our camera and projection
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationX(rotationAlpha) * Matrix.CreateRotationY(rotation)
* Matrix.CreateTranslation(position);
effect.View = Matrix.CreateLookAt(cameraPosition, camLook, Vector3.Up); //Vector3.Zero, Vector3.Up);
effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
aspectRatio, 1.0f, 1000000.0f);
}
//Draw the mesh, will use the effects set above.
mesh.Draw();
}
}
And I'm trying to add projectile objects to a list<projectile> ProjList.
I have tried ProjList.Add(new projectile(modelPosition, modelVelocityAdd, modelRotation, modelRotationAlpha); but this doesn't seem to work.
Ideas