Author Topic: Changeing the intial position of a fired bullet.  (Read 775 times)

I was playing around with a shotgun script and was able to take off the spread of the gun, making it fire accurately. I then took out the for function, to make it shoot only one bullet, I copied the code that seems to create the bullet, and pasted it again, thus hopefully making it shoot two bullets. In the code there's two bolded lines, (bolding dosn't work in code) and I thought they'd make one of the bullets start off higher when it was fired but it didn't. Can anyone explain how to change the in ital position of a bullet?

Edit, the code I tried to change position is here:
Code: [Select]

%addvector = MatrixCreateFromEuler(0 @ " " @ 1 @ " " @ 0);
%shotvector =  VectorAdd(%addvector,%obj.getMuzzlePoint(%slot));

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %shotvector;
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};

And this is it in a bigger context:


Code: [Select]

%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (0) * 10 * 3.1415926 * %spread;
%y = (0) * 10 * 3.1415926 * %spread;
%z = (0) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);

%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (2) * 10 * 3.1415926 * %spread;
%y = (2) * 10 * 3.1415926 * %spread;
%z = (2) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%addvector = MatrixCreateFromEuler(0 @ " " @ 1 @ " " @ 0);
%shotvector =  VectorAdd(%addvector,%obj.getMuzzlePoint(%slot));

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %shotvector;
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};

Code: [Select]
%mypos = VectorAdd(MatrixCreateFromEuler(0 @ " " @ 0.1 @ " " @ 0),%obj.getMuzzlePoint(%slot));

So that won't work, right?

Yeah, I still need help on this, scripts don't really help.