Okay so here is what I am trying to do.
I have modeled a Star Destroyer and given it 12 weapon bones. Essentially it has a bank of weapons consisting of a front, middle and rear gun on the top right, top left, bottom right and bottom left sides.
I have been trying to get the weapons to fire intelligently, based on what direction you are aiming. The script calculates whether you are aiming forward, left, right, backward, up or down, then selects a weaponset to use based on that direction. The weaponset is just an array of 6 numbers that correspond to the weapons I want the vehicle to fire based on the direction you are currently aiming. This way, say you are aiming to the right, you would be firing the 3 weapons on the top right and the 3 on the bottom right. This keeps the vehicle from using all the weapons on the vehicle and having the lasers fire from the side that can't realistically hit the target and prevents them from firing through the geometry of the vehicle towards the target.
So I have basically had this working but not to my satisfaction. Here are my problems.
1. I would like to calculate which direction you are aiming from one position, then fire the weapons from another. It would really be helpful to just use the root bone, which I have made center of mass, as the center of rotation for checking your aiming. That way when you aim up, you are actually aiming up above the center of the ship. In the past I have had to rotate where you calculate your currentaim from as I cycle through the array of weapons. This ends up with wierd weapon selections at times when a target might possibly change aiming zones in relation to the weapon aiming, while not necessarily changing relation to the center of the vehicle as a whole.
2. Currently I am having issues getting the Weapon[ActiveWeapon].Currentaim to update each tick, from the same weapon. I would think that the .CurrentAim (which is a rotator) changes as I change my aim, but it seems like this value is only getting updated if I exit and reenter the vehicle, or switch weapons and take its .currentaim.
3. Will my rotations be determined by the local rotation axis of the joints as I set them up in Maya? I have Z up, X forward, and Y left. Does this make Z my Pitch and Y my Yaw? And where does each axis start at zero in terms of rotation? Basically what I am getting at is this, If I want to aim 45 degrees to the right and 45 degrees up is that going to be 8192 RUU in yaw to aim right, and 8192 RUU in pitch to aim up? If I wantedto align my weapon meshes to ship itself would I want the Z local rotation axis to be parallel to the surface normal(perpendicular to the surface) of the ship instead of up in Maya?
4. How would I take the aim from one weapon's location and transform it to another weapon so they were both firing at the same spot?
Here is basically what I have for the code, its currently not working, but might give you some insight into what I am trying to do:
I have modeled a Star Destroyer and given it 12 weapon bones. Essentially it has a bank of weapons consisting of a front, middle and rear gun on the top right, top left, bottom right and bottom left sides.
I have been trying to get the weapons to fire intelligently, based on what direction you are aiming. The script calculates whether you are aiming forward, left, right, backward, up or down, then selects a weaponset to use based on that direction. The weaponset is just an array of 6 numbers that correspond to the weapons I want the vehicle to fire based on the direction you are currently aiming. This way, say you are aiming to the right, you would be firing the 3 weapons on the top right and the 3 on the bottom right. This keeps the vehicle from using all the weapons on the vehicle and having the lasers fire from the side that can't realistically hit the target and prevents them from firing through the geometry of the vehicle towards the target.
So I have basically had this working but not to my satisfaction. Here are my problems.
1. I would like to calculate which direction you are aiming from one position, then fire the weapons from another. It would really be helpful to just use the root bone, which I have made center of mass, as the center of rotation for checking your aiming. That way when you aim up, you are actually aiming up above the center of the ship. In the past I have had to rotate where you calculate your currentaim from as I cycle through the array of weapons. This ends up with wierd weapon selections at times when a target might possibly change aiming zones in relation to the weapon aiming, while not necessarily changing relation to the center of the vehicle as a whole.
2. Currently I am having issues getting the Weapon[ActiveWeapon].Currentaim to update each tick, from the same weapon. I would think that the .CurrentAim (which is a rotator) changes as I change my aim, but it seems like this value is only getting updated if I exit and reenter the vehicle, or switch weapons and take its .currentaim.
3. Will my rotations be determined by the local rotation axis of the joints as I set them up in Maya? I have Z up, X forward, and Y left. Does this make Z my Pitch and Y my Yaw? And where does each axis start at zero in terms of rotation? Basically what I am getting at is this, If I want to aim 45 degrees to the right and 45 degrees up is that going to be 8192 RUU in yaw to aim right, and 8192 RUU in pitch to aim up? If I wantedto align my weapon meshes to ship itself would I want the Z local rotation axis to be parallel to the surface normal(perpendicular to the surface) of the ship instead of up in Maya?
4. How would I take the aim from one weapon's location and transform it to another weapon so they were both firing at the same spot?
Here is basically what I have for the code, its currently not working, but might give you some insight into what I am trying to do:
Code:
simulated function Tick(float DeltaTime) { local float EnginePitch, DesiredOpacity, DeltaOpacity, MaxOpacityChange, ThrustAmount; local TrailEmitter T; local int i; local vector RelVel; local rotator Target; local bool NewStreamerActive, bIsBehindView; local PlayerController PC; local int TargetSet1[6], TargetSet2[6], TargetSet3[6], TargetSet4[6], TargetSet5[6], TargetSet6[6]; TargetSet1[0]=0; TargetSet1[1]=10; TargetSet1[2]=3; TargetSet1[3]=6; TargetSet1[4]=1; TargetSet1[5]=9; TargetSet2[0]=5; TargetSet2[1]=2; TargetSet2[2]=11; TargetSet2[3]=8; TargetSet2[4]=5; TargetSet2[5]=8; TargetSet3[0]=0; TargetSet3[1]=7; TargetSet3[2]=2; TargetSet3[3]=6; TargetSet3[4]=1; TargetSet3[5]=8; TargetSet4[0]=3; TargetSet4[1]=10; TargetSet4[2]=5; TargetSet4[3]=9; TargetSet4[4]=4; TargetSet4[5]=11; TargetSet5[0]=0; TargetSet5[1]=4; TargetSet5[2]=2; TargetSet5[3]=3; TargetSet5[4]=1; TargetSet5[5]=5; TargetSet6[0]=9; TargetSet6[1]=7; TargetSet6[2]=11; TargetSet6[3]=6; TargetSet6[4]=10; TargetSet6[5]=8; Super.Tick(DeltaTime); //pitch=x roll=y yaw=z if ((time[(ActiveWeapon+5)%6] < Level.TimeSeconds) && (bWeaponIsFiring == True)) { time[ActiveWeapon]=Level.TimeSeconds + 1; Weapons[WeaponSet[(ActiveWeapon+5)%6]].bActive = False; // TargettingWeapon= 12+(ActiveWeapon%2); // Weapons[TargettingWeapon].bActive = True; Target = Weapons[WeaponSet[ActiveWeapon]].CurrentAim; if ((Target.Yaw<=8192 || Target.Yaw>=57344) && (Target.Pitch<8192 || Target.Pitch>57344)) { WeaponSet[ActiveWeapon]=TargetSet1[ActiveWeapon]; log("aiming forward " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else if((Target.Yaw>=24576 && Target.Yaw<=40960) && (Target.Pitch<8192 || Target.Pitch>57344)) { WeaponSet[ActiveWeapon]=TargetSet2[ActiveWeapon]; log("aiming back " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else if((Target.Yaw>8192 && Target.Yaw<24576) && (Target.Pitch<8192 || Target.Pitch>57344)) { WeaponSet[ActiveWeapon]=TargetSet3[ActiveWeapon]; log("aiming right " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else if((Target.Yaw>40960 && Target.Yaw<57344) && (Target.Pitch<8192 || Target.Pitch>57344)) { WeaponSet[ActiveWeapon]=TargetSet4[ActiveWeapon]; log("aiming left " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else if(Target.Pitch>=8192 && Target.Pitch<=24576) { WeaponSet[ActiveWeapon]=TargetSet5[ActiveWeapon]; log("aiming up " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else if(Target.Pitch>=40960 && Target.Pitch<=57344) { WeaponSet[ActiveWeapon]=TargetSet6[ActiveWeapon]; log("aiming down " $Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } else { log("How did we get here?"); log(Target.Yaw $" " $Target.Pitch); log("ActiveWeapon being calculated is " $ActiveWeapon); } for(i=0; i<6; i++) { log(WeaponSet[i]); } for(i=0; i<6; i++) { log(time[i]); } // Weapons[TargettingWeapon].bActive = False; Weapons[WeaponSet[ActiveWeapon]].bActive = True; log("Weapon is Firing?" $bWeaponIsFiring); log("Firing " $WeaponSet[ActiveWeapon]); log("ActiveWeapon being fired is " $ActiveWeapon); ActiveWeapon = ++ActiveWeapon % 6; } } defaultproperties { MaxPitchSpeed=100.000000 TrailEffectPositions(0)=(X=-185,Y=0,Z=0) TrailEffectPositions(1)=(X=-185,Y=-132,Z=0) TrailEffectPositions(2)=(X=-185,Y=132,Z=0) TrailEffectPositions(3)=(X=-175,Y=68,Z=20) TrailEffectPositions(4)=(X=-175,Y=68,Z=-25) TrailEffectPositions(5)=(X=-175,Y=-68,Z=20) TrailEffectPositions(6)=(X=-175,Y=-68,Z=-25) TrailEffectClass=ONSStarDestroyer.ONSStarDestroyerExhaust StreamerEffectOffset(0)=(X=-219.000000,Y=-35.000000,Z=57.000000) StreamerEffectOffset(1)=(X=-219.000000,Y=35.000000,Z=57.000000) StreamerEffectOffset(2)=(X=-52.000000,Y=-24.000000,Z=142.000000) StreamerEffectOffset(3)=(X=-52.000000,Y=24.000000,Z=142.000000) StreamerEffectClass=Onslaught.ONSAttackCraftStreamer StreamerOpacityRamp=(Min=1200.000000,Max=1600.000000) StreamerOpacityChangeRate=1.000000 StreamerOpacityMax=0.700000 UprightStiffness=500.000000 UprightDamping=300.000000 MaxThrustForce=10.000000 LongDamping=0.5000 MaxStrafeForce=10.000000 LatDamping=0.5000 MaxRiseForce=20.000000 UpDamping=0.5000 TurnTorqueFactor=0.000000 //30 TurnTorqueMax=0.000000 //30 TurnDamping=50.000000 //20 MaxYawRate=.000000 //1.5 PitchTorqueFactor=.5000000 PitchTorqueMax=.5000000 PitchDamping=5.000000 RollTorqueTurnFactor=5.000000 RollTorqueStrafeFactor=5.000000 RollTorqueMax=5.000000 RollDamping=.5000000 StopThreshold=50.000000 MaxRandForce=0.000000 RandForceInterval=0.750000 DriverWeapons(0)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopRightFront") DriverWeapons(1)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopRightMiddle") DriverWeapons(2)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopRightRear") DriverWeapons(3)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopLeftFront") DriverWeapons(4)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopLeftMiddle") DriverWeapons(5)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachTopLeftRear") DriverWeapons(6)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomRightFront") DriverWeapons(7)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomRightMiddle") DriverWeapons(8)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomRightRear") DriverWeapons(9)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomLeftFront") DriverWeapons(10)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomLeftMiddle") DriverWeapons(11)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="GunAttachBottomLeftRear") DriverWeapons(12)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="root") DriverWeapons(13)=(WeaponClass=ONSStarDestroyer.ONSStarDestroyerGun,WeaponBone="root") RedSkin=Texture'ONSStarDestroyer.SD_texture' BlueSkin=Texture'ONSStarDestroyer.SD_texture' IdleSound=ONSSDSounds.SD-LP-1 StartUpSound=ONSSDSounds.SD-LP-1 ShutDownSound=ONSSDSounds.SD-LP-1 StartUpForce="AttackCraftStartUp" ShutDownForce="AttackCraftShutDown" DestroyedVehicleMesh=ONSDeadVehicles-SM.AttackCraftDead DestructionEffectClass=Onslaught.ONSVehicleExplosionEffect DisintegrationEffectClass=Onslaught.ONSVehDeathAttackCraft DestructionLinearMomentum=(Min=50000.000000,Max=150000.000000) DestructionAngularMomentum=(Min=100.000000,Max=300.000000) DamagedEffectOffset=(X=-120.000000,Y=10.000000,Z=65.000000) ImpactDamageMult=0.001000 VehicleMass=4.000000 bTurnInPlace=False bShowDamageOverlay=True bDriverHoldsFlag=False bCanCarryFlag=False ExitPositions(0)=(Y=300.000000,Z=100.000000) ExitPositions(1)=(Y=-300.000000,Z=100.000000) ExitPositions(2)=(X=350.000000,Z=100.000000) ExitPositions(3)=(X=-350.000000,Z=100.000000) ExitPositions(4)=(X=-350.000000,Z=-100.000000) ExitPositions(5)=(X=350.000000,Z=-100.000000) ExitPositions(6)=(Y=300.000000,Z=-100.000000) ExitPositions(7)=(Y=-300.000000,Z=-100.000000) EntryPosition=(X=100.000000) EntryRadius=1000.000000 TPCamDistance=500.000000 TPCamLookat=(X=0.000000,Z=0.000000) TPCamWorldOffset=(Z=200.000000) DriverDamageMult=0.000000 VehiclePositionString="in a Star Destroyer" VehicleNameString="Star Destroyer" RanOverDamageType=Onslaught.DamTypeAttackCraftRoadkill CrushedDamageType=Onslaught.DamTypeAttackCraftPancake FlagBone="root" FlagOffset=(Z=80.000000) FlagRotation=(Yaw=32768) GroundSpeed=5.000000 HealthMax=1000.000000 Health=1000 Mesh=SkeletalMesh'ONSStarDestroyer.StarDestroyer' SoundVolume=160 CollisionRadius=5.000000 CollisionHeight=5.000000 Begin Object Class=KarmaParamsRBFull Name=KParams0 KInertiaTensor(0)=1.000000 KInertiaTensor(3)=3.000000 KInertiaTensor(5)=3.500000 KCOMOffset=(X=-0.250000) KLinearDamping=0.000000 KAngularDamping=0.000000 KStartEnabled=True bKNonSphericalInertia=True KActorGravScale=0.000000 bHighDetailOnly=False bClientOnly=False bKDoubleTickRate=True bKStayUpright=True bKAllowRotate=True bDestroyOnWorldPenetrate=True bDoSafetime=True KFriction=0.500000 KImpactThreshold=300.000000 End Object KParams=KarmaParamsRBFull'Onslaught.ONSAttackCraft.KParams0' }
Comment