Author Topic: Gun Facing Backwards in 1st person  (Read 893 times)

Well, I made a gun add-on and everything works fine except the gun is facing backwards in 1st person, but in 3rd person the gun is facing in the right direction.

You probably changed the rotation in the weaponImage.


Could do something with the onfire function.

You probably changed the rotation in the weaponImage.
I don't think I changed that, but here is the script.                                                                                                 


Quote
datablock ParticleData(RifleSmokeParticle)
{
   dragCoefficient      = 3;
   gravityCoefficient   = -0.5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 1525;
   lifetimeVarianceMS   = 55;
   textureName          = "base/data/particles/cloud";
   spinSpeed      = 10.0;
   spinRandomMin      = -500.0;
   spinRandomMax      = 500.0;
   colors[0]     = "0.5 0.5 0.5 0.9";
   colors[1]     = "0.5 0.5 0.5 0.0";
   sizes[0]      = 0.15;
   sizes[1]      = 0.25;

   useInvAlpha = false;
};
datablock ParticleEmitterData(RifleSmokeEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 0;
   ejectionVelocity = 1.0;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "RifleSmokeParticle";
};


//bullet trail effects
datablock ParticleData(RiflebulletTrailParticle)
{
   dragCoefficient      = 3;
   gravityCoefficient   = -0.0;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 625;
   lifetimeVarianceMS   = 55;
   textureName          = "base/data/particles/thinRing";
   spinSpeed      = 10.0;
   spinRandomMin      = -500.0;
   spinRandomMax      = 500.0;
   colors[0]     = "0.3 0.3 0.9 0.4";
   colors[1]     = "0.5 0.5 0.5 0.0";
   sizes[0]      = 0.15;
   sizes[1]      = 0.25;

   useInvAlpha = false;
};
datablock ParticleEmitterData(RiflebulletTrailEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "RiflebulletTrailParticle";
};

AddDamageType("Rifle",   '<bitmap:add-ons/Weapon_Rifle/CI_rifle> %1',    '%2 <bitmap:add-ons/Weapon_Rifle/CI_rifle> %1',0.5,1);
datablock ProjectileData(RifleProjectile)
{
   projectileShapeName = "./bullet.dts";
   directDamage        = 150;
   directDamageType    = $DamageType::Rifle;
   radiusDamageType    = $DamageType::Rifle;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 25;
   brickExplosionMaxVolume = 200;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloati ng = 200;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse        = 1200;
   verticalImpulse     = 1400;
   explosion           = GunExplosion;
   particleEmitter     = RiflebulletTrailEmitter;

   muzzleVelocity      = 2000;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 4000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";
};

//////////
// item //
//////////
datablock ItemData(RifleItem)
{
   category = "Weapon";  // Mission editor category
   className = "Weapon"; // For inventory system

    // Basic Item Properties
   shapeFile = "./rifle.dts";
   rotate = false;
   mass = 1;
   density = 0.2;
   elasticity = 0.2;
   friction = 0.6;
   emap = true;

   //gui stuff
   uiName = "Rifle";
   iconName = "./icon_rifle";
   doColorShift = true;
   colorShiftColor = "0.25 0.25 0.25 1.000";

    // Dynamic properties defined by the scripts
   image = RifleImage;
   canDrop = true;
};


////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(RifleImage)
{
   // Basic Item properties
   shapeFile = "./rifle.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = "0.2 0.55 -0.35";
   rotation = eulerToMatrix( "0 0 0" );
   eyeRotation = eulerToMatrix( "0 0 0" );
   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = true;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = BowItem;
   ammo = " ";
   projectile = RifleProjectile;
   projectileType = Projectile;

   casing = GunShellDebris;
   shellExitDir        = "1.0 -1.3 1.0";
   shellExitOffset     = "0 0 0";
   shellExitVariance   = 15.0;   
   shellVelocity       = 7.0;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;
   minShotTime = 2000;   //minimum time allowed between shots (needed to prevent equip/dequip exploit)

   doColorShift = true;
   colorShiftColor = RifleItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
   stateName[0]                     = "Activate";
   stateTimeoutValue[0]             = 0.15;
   stateTransitionOnTimeout[0]       = "Ready";
   stateSound[0]               = weaponSwitchSound;

   stateName[1]                     = "Ready";
   stateTransitionOnTriggerDown[1]  = "Fire";
   stateAllowImageChange[1]         = true;
   stateSequence[1]   = "Ready";

   stateName[2]                    = "Fire";
   stateTransitionOnTimeout[2]     = "Smoke";
   stateTimeoutValue[2]            = 0.14;
   stateFire[2]                    = true;
   stateAllowImageChange[2]        = false;
   stateSequence[2]                = "Fire";
   stateScript[2]                  = "onFire";
   stateWaitForTimeout[2]         = true;
   stateEmitter[2]               = GunFlashEmitter;
   stateEmitterTime[2]            = 0.05;
   stateEmitterNode[2]            = "muzzleNode";
   stateSound[2]               = GunShot1Sound;
   stateEjectShell[2]       = true;

   stateName[3] = "Smoke";
   stateEmitter[3]               =          RifleSmokeEmitter;
   stateEmitterTime[3]            = 2.00;
   stateEmitterNode[3]            = "muzzlePoint";
   stateTimeoutValue[3]            = 2.00;
   stateTransitionOnTimeout[3]     = "Reload";
   stateWaitForTimeout[3]         = true;

   stateName[4]         = "Reload";
   stateSequence[4]                = "Reload";
   stateTransitionOnTriggerUp[4]     = "Ready";
   //stateSequence[4]   = "Ready";

};

function RifleImage::onFire(%this,%obj,%slot)
{
   if(%obj.getDamagePercent() < 1.0)
      %obj.playThread(2, shiftAway);
   Parent::onFire(%this,%obj,%slot);   
}
       
« Last Edit: October 06, 2008, 10:58:33 AM by Nick4t »

Below the line

Code: [Select]
rotation = eulerToMatrix( "0 0 0" );
Add

Code: [Select]
eyeRotation = eulerToMatrix( "0 0 0" );
and see if that does anything.

Still nothing D: (Updated code above)

Change the eyeRotation one of the first two numbers to 180 and see if you get anything. Could be a wierd model problem.

Change the eyeRotation one of the first two numbers to 180 and see if you get anything. Could be a wierd model problem.
Well when I changed the first number to 180 the gun was invisible in 1st person, when I changed the second number to 180 the gun was backwards and upside down, and when I changed the 3rd number to 180 the gun was facing the right way but it was very zoomed in (I could only see the tip of the gun).

Well when I changed the first number to 180 the gun was invisible in 1st person, when I changed the second number to 180 the gun was backwards and upside down, and when I changed the 3rd number to 180 the gun was facing the right way but it was very zoomed in (I could only see the tip of the gun).
Try messing around with the offset a bit.