武器系统Weapon system.docx
《武器系统Weapon system.docx》由会员分享,可在线阅读,更多相关《武器系统Weapon system.docx(13页珍藏版)》请在冰点文库上搜索。
武器系统Weaponsystem
武器系统(Weaponsystem)
1.Definitionofweapondatasetsandhowtoequipplayers
1.Copytheweaponmodelresourcestothedata/shapesdirectory
2.Createanewweapons.Csscriptfileunderthegame/serverdirectoryandexecutethescriptintheonServerCreatedfunctionofgame.cs
3.ThedatablockkeywordisusedtodefinetheShapeBaseImageDatadatasetobjectintheweaponsscript,whichiscalledcrossbowImage
4.InthecrossbowImagedatasetdefinition,addthefileoftheshapeFileattributetotheweaponmodel
5.Gobacktothegame.csscripttofindthecreatePlayerfunction,andthencallthedeviceweaponfunctiontoequiptheplayerwithaweaponaftercreatingtheplayercode
Weaponequipmentfunction:
playerobject.MountImage(0)
Runthetesttoseeiftheweaponappearsintheplayer'shand
Repeattheabovestepstoequiptheplayerwithm16andbombweapons
Ii.Howdoestheweaponappearinthegamescene,aftertheplayerpicksuptheequipmenttothehand
6.Annotatetheplayerwiththeweapon'sfunction,enterthegamesceneeditor,andleaveanyStaticShapeinthescene
7.ThedatablockkeywordisusedtodefinetheItemDatasetobjectintheweaponsscript,whichiscalledcrossbow,andtheweaponmodelisdefinedastheitemdataset
8.FindtheStaticShapeobjectinthetaskdefinitionscriptflat.Misfile,replacetheobjectwiththeItemobject,deletetheshapeFileattributeoftheobject,andaddthedatablockattributetothedatasetoftheweaponItem
Runningtestweaponscanbefoundingamescenarios
9.Addtheattributestatic="1"intheItemobject;Lettheweaponsinthegamescenenotmoveandincreasetherotate="1"attributetorotatetheweaponinthegamescene
Runthetesttoseeiftheaboveattributesareineffect
10.AddcollisiondetectionmemberfunctiononCollision(%this,%obj,%col)fortheweaponobjectdatasetobject,andcalltheplayer'sweaponfunctioninthefunctiontolettheweaponappearintheplayer'shand
TheonCollisionfunctionparameterindicatesthat%thisistheobjectoftheweaponitem%objastheobjectoftheweaponitem%colistheobjectthatobjectstotheobjectistheplayer
Thetestplayerwillbeabletopickuptheweapon
3.Thestatuschangeoftheweaponisrealizedbyaddingmembersoftheweapondatasetobject
11.TheeyeOffsetattributeisaddedtotheweapondatasetobject,sothatthepositionoftheweaponinthefirstpersonstatewillnotbemoved
EyeOffset="0.10.4-0.6";
Runthetesttoseeiftheweapon'spositionrelativetotheeyechangesinthefirstperson
12.Thedefinitionattributeoftheweaponstateisaddedtotheweapondatasetobjectsothattheweaponcanbeswitchedbetweenseveralstates
//preactivationstatus
StateName[0]="Preactivate";
StateTransitionOnLoaded[0]="Activate".
//thestateofthetransitioncondition//transformation
StateTransitionOnNoAmmo[0]="NoAmmo";
//activation
StateName[1]="Activate".
StateTransitionOnTimeout[1]="Ready";
StateTimeoutValue[1]=0.6;
StateSequence[1]="Activate".
//standby
StateName[2]="Ready";
StateTransitionOnNoAmmo[2]="NoAmmo";
StateTransitionOnTriggerDown[2]="Fire".
//fire
StateName[3]="Fire".
StateTransitionOnTimeout[3]="Reload";
StateTimeoutValue[3]=0.1;
StateFire[3]=true;
StateRecoil[3]=LightRecoil;
StateAllowImageChange[3]=false;
StateSequence[3]="Fire".
StateScript[3]="onFire";
//ammunition
StateName[4]="Reload";
StateTransitionOnNoAmmo[4]="NoAmmo";
StateTransitionOnTimeout[4]="Ready";
StateTimeoutValue[4]=0.5;
StateAllowImageChange[4]=false;
StateSequence[4]="Reload";
StateEjectShell[4]=true;
//noammunition
StateName[5]="NoAmmo";
StateTransitionOnAmmo[5]="Reload";
StateSequence[5]="NoAmmo";
StateTransitionOnTriggerDown[5]="DryFire";
//dryfire
StateName[6]="DryFire";
StateTimeoutValue[6]=1.0;
StateTransitionOnTimeout[6]="NoAmmo";
Runthetesttoseeiftheweaponhasastatuschangeeffect
13.Jointhememberfunctionoftheweapondatasetobject(%this,%obj,%slot),callthefunctionsetImageAmmo,whichsetstheweaponcartridgeinthefunction,andequipitwithammunitionwhilepickinguptheweapon
TheonMountfunctionparameterindicatesthat%thisistheweapondatasetobject%objastheobjectoftheweapon'sobject%slotfortheweapon'sbulletobject
Whethertheweaponissettousetheammunitionfunction:
playerobject.SetImageAmmo(bulletsobject,whethertherearebullets(trueorfalse));
Runthetesttoseeiftheweaponhasammunition
Iv.Bulletsthataddweaponstoachieveweapon'sfiringfunction
14.ThebulletProjectileDatasetobjectthatdefinestheweaponisCrossbowProjectile,andtheprojectileShapeNamepropertyofthisobjectisassociatedwiththebulletmodelfile
15.AddshotforweaponsdatasetonFire(%this,obj,%%slot)memberfunctions,createabulletobjectProjectileinfunction,forthebulletobjectadddatablockpropertiesforCrossbowProjectile,addinitialVelocityattributevalueforthe"001",addinitialPositionattributevalueis%obj.ThegetMuzzlePointslot(%),addsourceObjectvalueis%obj
TheononFirefunctionparameterindicatesthat%thisistheweapondatasetobject%objistheobjectthatisequippedwithweaponandtheplayer%slotisthebulletobjectforthatweapon
Propertydescription:
TheinitialdirectionandvectoroftheinitialVelocity//bullet
InitialPosition//initialpositionofthebullet
SourceObject//anobjectthatfiresabullet(action:
thebulletwillnotcollidewithitsobject)
Runthetesttoseeiftheweaponisfiredafterfiring
16.FromTorqueinstallerSDK/example/starter.TheFPS/client/UIdirectoryiscopiedtothecrossHair.PNGsightpicturetohergameproject/client/UIdirectory,andopenthedirectoryplayGui.GUIfilefoundinthefiletocreateGuiCrossHairHudtypegameobjectcodeiscopiedtotheproject/client/UI/playGuiGUIfile
Runthetesttoseeifthereisasightinthegame
17.Usethefollowingmemberfunctionstocompletethecalculationofthedirectionofthebullet:
Memberfunctiondescription:
Playerobject.GetMuzzlePoint(%slot)//getthelocationofthemuzzle
Playerobjects.
GetMuzzleVector(%slot)//thedirectionofthemuzzle
Playerobject.GetVelocity();//avectorthatmovesthedirectionandspeedoftheplayer
Vectorcalculationfunction:
V3isequaltoVectorAdd(v1,v2)//youcanaddvectorsv1andv2togetthev3vector
V3isequaltoVectorScale(v1,10)//I'mgoingtozoomin10timesthevectorv1togetthev3vector
Formula1:
theinitialdirectionofthebullet=thevectorofthedirectionofthegun
Runthetesttoseeifthedirectionofthebulletinthegameisalignedwiththedirectionofthegun
Formula2:
theinitialdirectionofthebullet=300timesthevectorofthedirectionofthegun
Runthetesttoseeifthebulletisgettingfasterinthegame
Formula3:
theinitialdirectionofthebulletisequalto300timesthevectorofthedirectionofthegun,plusthevectorofthemovementofthecharacter
Runthetesttoseeifthedirectionofthebulletinthemovementisinlinewiththesight
18.AdjustthepropertiesofProjectileDataforthebulletdatasetandachievetheeffectofthegrenadestillout
Lifetime=5000;//determinehowlongitwilltaketobedeletedfromthegameworld
FadeDelay=5000;//howlongafterthegenerationhasbecometransparent(iehidden)
BounceElasticity=0;//bounceheightaftercollision
BounceFriction=0;//thelostmomentumofthebounce
IsBallistic=true;//confirmthatthegravitationalpullofgravityisnotvalidforthegravityoftheearth.
GravityMod=0.001;//gravity
6.Usetheattachedparticlestorealizetheparticleeffectofweaponbullets
19.Thedataset(particleledata)objectthatcreatestheparticlebeforedefiningtheweaponscriptisCrossbowBoltParticle
20.ThetextureNameattributeisspecifiedintheCrossbowBoltParticledatasetasthepathofsmoke.PNG
21.Createtheparticleemitterdataset(ParticleEmitterData)objectCrossbowBoltEmitter
22.SpecifytheparticleattributeasCrossbowBoltParticleintheCrossbowBoltEmitterdataset
23.SpecifytheparticleEmitterattributeinthebulletdatasetobjectCrossbowProjectileasCrossbowBoltEmitter
Runthetesttoseethebulleteffect
24.AddthefollowingattributestotheCrossbowBoltParticleobjecttoseetheeffect
DragCoefficient=0.0;
GravityCoefficient=0.35;//gravityisnegativetomakeitupward.
InheritedVelFactor=0.00;//inertiaobtainedfromotherobjects.
LifetimeMS=580;//thedisplaytimeoftheparticleislong.
LifetimeVarianceMS=150;
UseInvAlpha=false;
SpinRandomMin=15.0;
SpinRandomMax=15.0;
Colors[0]="0.80.60.00.1";//setthecolorofasequenceparticle
Colors[1]="0.80.650.00.1";
Colors[2]="0.00.00.00.0";
Sizes[0]=1.0;//setthezoomsizeofasequenceparticle.
Sizes[1]=2.0;
Sizes[2]=4.0;
Times[0]=0.1;//setthetimeperiodoftheparticlesequence.
Times[1]=0.4;
Times[2]=1.0;
25.AddthefollowingpropertiestotheCrossbowBoltEmitterobjecttoseetheeffect
EjectionPeriodMS=15;//howmanymillisecondstoemitaparticle.
PeriodVarianceMS=5;
EjectionVelocity=0.35;//thevelocityoftheparticlemoving.
VelocityVariance=0.20;
ThetaMin=0.0;MinimumemissionAngleof//particleemitter(xaxis)
ThetaMax=60.0;MaximumemissionAngleof//particleemitter(xaxis)
Runthetesttoseethemodifiedbulletparticleeffect
7:
realizetheeffectofbulletexplosionparticle
26.
Repeatthe19-22stepsinpart6tocreate:
CrossbowExplosionParticleparticledatasets(ParticleData