Вы находитесь на странице: 1из 27

blender.

org
code.blender.org
Org:Institute/Open
projects/Apricot/BGELogic
Login/createaccount
<Org:InstituteOpenprojectsApricot
BlenderInstitutepage
Discussion
Viewsource
History
Page
Whatlinkshere
Relatedchanges
Permanentlink
From BlenderWiki
Blender Game Engine Logic
BCampbellBaonakaideaman42
Overview
Thegameisseparatedintoanumberofblendfiles.characters,levelsandprops.The
levelsandpropshavealmostnologic,onlypropertiesassignedtothemthatthe
charactersusetodefinehowtointeractwiththem.
Thelevelscontainmostlystaticscenery,linkingincharacters,propsandeffectsas
groups.
Havingacharacterwithitscamera,animations,soundsandlogicinanexternal
blendfileisextremelypowerfulnotonlybeingabletolinkthe1characterinto
multiplelevels,butalsohavemultipleinstancesofthatcharacterinalevel.
Logic Sharing
Oncewehadthelogicforthesheep,wewantedtobeabletoaddextracharacters
withouthavingtoredothelogic.Thiswasmadepossiblebytherecentadditionof
groupinstancesinthegameengineaddedespeciallyforApricot.
Characterspecificobjectssuchasthearmature,meshandshadowmesheach
characterareparentedtoadummymeshthatrunsthelogic.Allthreegroupshare
thelogicobjectsbuthaveuniquearmatureandmeshes.
Toavoideachcharacterbehavinginthesameway,ascriptrunswhenthecharacter
startsthatsetsa"type"propertybasedonthechildren.Thetypepropertydetermines
ifthecharactercanattack,getkicked,carriedandhowaggressivetheyare.
Thereare2playablecharacters(FrankieandMomo)whichalsosharelogicbuthave
theirownuniquemeshandarmature.
Nochangesinbehaviorareneededhowevertheydoneedtousedifferentkey
layoutsandhavetheirownsectionofthescreen(splitscreen).Aswiththesheepthis
isdoneonwhenthecharacterstarts,forthemomentonly1or2playersare
supportedatoncebutaddingmorewouldbetrivial.
States
StatesareanewadditiontoblenderaddedfortheApricotproject,allowingusto
grouplogicintostatesthatcaneachbeenabledanddisabled(youcouldthinkof
themaslogiclayers).Stateswereusedheavilywithallcomplexgamelogic.Frankie
forexamplehasstatessuchasidle,walking,running,falling,gliding,hanging,
drowninganddeath.Eachstatehasanumberofsensorandactuatorsthatwillswitch
statesundercertainconditions.
Idlestatefromfrankie.blend
Hereisanexampleofhowstatesswitchduringgameplay
InitialState>Falling
GroundCollision>IdleState
UpKey>WalkState
NoGroundCollision>FallState
WaterCollision>DrownState
Logic Elements
Frankies Camera
Thisfileshowshowtheapricot
cameraworks.Althougha3rd
personcamerafacingforwardis
notoverlycomplexthereareare
stillvariousissuestoovercome.
Theinitialproblemwehadwith
blender'scamerawasthatFrankie
couldbecomeobscuredbyobjects
whichmadethegameunplayable.
Westartedbyparentingacamera
toFrankie,usingblender'sslow
parentfeaturetodampenthe
camerasresponsetoFrankie,
avoidingjitterandjarringmotion.
Topreventtreesandwallsgetting
inthewayofthecamera,aray
sensorfromFrankiepointstowardsthecameraandusesapythonscripttoscalethe
cameraparentbasedonthecollisionlocation.
Notes
Thereisadummycharacterinthisfiletotestmovement,addedsothecamera
hassomethingtolookat.
Thescenewiththeterrainandpillarsisa'SetScene'called"example_scene".
KeysformovementareArrowKeysandSpaceforjump.Keys1and2setorbit
onandoff.
Objects and their use(machingfankie.blend)
FrankieParentmeshwithallplayercontrolandproperties
FrankieDummyMeshthatshowsFrankie,isarigandmeshinfrankie.blend
Camera_RayAnemptythattracksthecamerafromFrankie'sposition.This
castsaraytothecameraanddetectsifanythingisinthewayoftheview.
Camera_ScalerThisisaparenttothecamerasoscalingitchangesthe
cameradistancefromFrankie.Thescaleiscontrolledbyapythonscriptthat
usestheCamera_Rayhitpositiontosetthescale.(thisistheonlyscriptused
bythiscamerasetup).Thereisalsoanorbitmodethatmakesthisobjectrotate
abouttoseefrankiebetterfromallsideswhileheisidle,drowningordead.
SlowVertParemtThisistheparentofthecamera,slowparentisusedso
changesinscaleorFrankieturningarenotappliedinstantlytothecamera.We
neededtouseavertexparentforthecameraotherwisethecamerawouldhave
scaleappliedtoitwhichcauseddistotionofthe3Dview.
MainCamThemaincameratrackstotheCamera_Ray
Frankie's States (Simplified)
Thischaracterlogicexampleis
basedonFrankie'slogicandshows
howyoucanusestatestocontrol
behaviorwithoutsettingany
propertiesorrunningpython
scripts.
Pythonshouldbeusedtoaddmore
advancedfunctionality,butusing
stateshelpsgivescriptsalimited
contextkeepingthemsmaller.
Keys
Up,Left,RightMovement
SpaceJump
Level Properties
groundusetodetectflooryoucanwalkon
killsendsyoutothedeathstate
States
1Idlestate.Canjump,walkandturnfromhere
2Walkstate.Canjump,idleandturnfromhere
3JumpState.
Onlyeverenabledforonelogictick,addsupwardforceandgoesintofall
stateimmediately.Thisisbecausemotionfromotherstates(walkinthiscase)
caninterferewiththejumpforce.
4FallState.Canlandfromhere.
Thisstateisenabledonstartup(noticetheblackdotoverthestate)andis
enabledwheneverFrankieisnottouchinga'ground'propertyobject.
6GeneralStateforturning,andcheckingifFrankietouchesany'kill'objects.
ThisstateisalwaysenabledwhileFrankieisalive,havingoneofthesestates
isusefulforsituationsyouwantthecharacterreacttoregardlessofhiscurrent
behavior.
15Death,thisstateturnsoffthegeneralstate,removinguserinput,waitsfor
4secondsandendstheobject.
Level Portals
Thiscollectionofblendfilesshow
howasinglecharactercanbe
linkedintoanynumberofscenes
andblendfiles,easilymoving
betweenthemwithportals.
Thecharacterisagroupofobjects
withgamelogicandacamera.
Thisgroupisthenlinkedinto
manylevelskeepingthecharacter
logicinoneplacewhereitcanbe
edited.
Theseexamplesfocusonhowwe
didportals,whichcandothe
following.
movetoanotherlocationin
thelevel.
movetoanothersceneintheblendfile(objectifit'sdefined)
movetoanotherblendfile(sceneandobjectiftheyaredefined)
keepthepropertiesofthecharactersuchaslifeandinventorybetweenscenes
andblendfiles.
Tomakeaportaljustaddanobjectyoucancollidewithandgiveittheproperty
"portal",value"SomeObjectName"foreg.Ontouchingtheportalyou'llbe
transportedtoanobjectcalled"SomeObjectName".
Ifyouwanttomovetoanothersceneaddtheproperty"portal_scene",value
"MyOtherScene"foreg.
Togointoanotherblendfileaddtheproperty"portal_blend",value
"//level_2.blend"foreg.Thevalueisapathtoanotherblendfile,the//prefixmeans
it'sinthesamedirectoryasthecurrentblendfile.
Whenusing"portal_scene"or"portal_blend"properties,the"portal"propertymust
bepresent,ifyoudontwanttosetanobjectlocation,it'svalueshouldbeanempty
string.
ThepropertiesdescribedworkthesamewayastheApricotlevels,however
characterscriptsweremodifiedforthepurposeofthisexample.
Takealookattheportalsinthisdirectoryforexamples.
Splashing
Hereisanexampleshowinghowsplashesarecreatedforthewaterandlavalevels.
Waterobjectsneedcollisionsensorslinkingto"splash_logic"'scontroller.Inthis
casethereare2waterobjects,butthereisnolimit.
splash_logicrunsapythonscriptcalled"detect_splash"wheneverthereare
collisions,The"detect_splash"scriptmoves"splash_logic"toeachcollision
locationandaddsasplashobject.
Thisway.manysplashescanhappenatonce.
Itisuptotheobjectsthatlandonthewatertofloat,sinkorberemoved,theyonly
needtocollidewiththewater.Inthisexamplethecube'sdynamicsaresuspended
anditisremovedafter200logicticks.
Theemptyobjectsabovearethere
tocreateobjectsthatmakea
splashhoweveranyobjectcould
bedropped.
Thesplashobjectitsselfmustbe
inadisabledlayerforthe
AddObjectactuatortowork.See
layer20.
2 Player Split Screen
Thisfileshowshow2instancesof
thesamecharactergroupcanhave
theirownkeysandscreenassigned
onstarting.
Thisisdonebyhavingapython
initscriptforeachcharacterthat
assignsauniqueID,usedto
configureeachdifferently.
Oncethescriptruns,thestateis
changedtorespondtouserinput
only.Thecharacterobjectsinthis
scenearedupligroupinstances,
changetothe"character_group"
scenetoseetheirlogicandseethe
"frank_init_2player"scripttosee
howtheyareinitialized.
Usethearrowkeysforplayerone,
WASDkeysforplayertwo.
Menu
ThisblendfileshowsasimplifiedversionoftheYoFrankiestartmenu.
themenuhasthefollowing
functionality
inputfrommouse,keyboard
orjoystick
menuitemscanloadscenes,
blenderfilesortriggeryour
ownactuators.
toggleandradiomenuitems
canbeusedtoset
configurationoptions.
optionscanbesavedan
loadedtoafileusingnew
functionalityinthegame
actuator.
logicisgeneric,reusable
betweenmultiplemenus.
Implementation
Thebasisofthemenuisquitesimple,allobjectsstartingwith"item_"are
alphabeticallysortedandtreatedasmenuitems.Only1itemcanbeactiveatatime
bypressingup/downorpassingthemouseoverit.Pressingenterorclickingwill
executethemenuitemsaction.
The"menu_select"scriptiswheremostofthemenulogiciscontrolled.Itrunson
the"menu_logic"object,reactingtouserinputbyscanningthescenefor"item_"
prefixedobjectsandadjustingtheirpropertiesaccordingly.
The"active"propertyisusedbyallitems.Whensetto1,theitemssensordetects
thisandplaysananimation.ForYoFrankiewechosetouseinvisibleitemssowe
couldattachanimationstooneormoreobjects,givingusalargerareaforthemouse
toactivateaswell.
Item Activation Types
trigger
Theseitemsonlyneedanextra"trigger"property.Whenthemenuitemisactivated
triggerissetto1.Theitemsownlogicneedstocheckforthetriggervaluetoacton
it.Onceexecutedthetriggervalueneedstobesetbacktozero.Seethemenuitems
"Quit","SaveConfig"and"LoadConfig"
portal
Usingthesamepropertiesasinthelevels,portalscanloadblendfiles,scenesand
objects(tosettheinitiallocation).
thepropertiesare
"active":describedabove.
"portal":objectname
"portal_scene":scenename
"portal_blend":blendfilename
Seethemenuitems"OpenBlendfile","Configure"and"Back"forexamplesofa
portal.
Configuration
Ifyouwanttoconfiguresettingsinamenu,youcanusethepythondictionary
"GameLogic.globalDict"whichiskeptbetweenloadingfilesandcanbesavedand
loadedtoafilewiththegameactuator.
AllgameconfigurationiskeptinadictionaryGameLogic.globalDict['conf'].
Therearecurrently2typesofbuttonsthatwillautomaticallyadjustthepython
dictionarywhenactivated.Bothusethe"conf_key"propertytospecifywhich
settingischanged.
Eventhroughthereareonlyafewbuttons,manyconfigurationbuttonscanbeadded
withoutmakinganychangestothemenusinnerworkings.
seethe"init_options"scriptandmenuitemsintheoptionsscenetoseehowthey
work.
Toggle (configuration)
Thisisfairlysimple,thetogglebuttonswitchesvalueintheconfigurationdictionary
onandoff.
"active":describedabove.
"toggle":0or1,themenuitemchecksthistodisplayalargerdotwhen
enabled.
"conf_key":togglethisoption,GameLogic.globalDict['conf'][conf_key]=
TrueorFalse
Radio (configuration)
Unlikethetogglebutton,multipleradiobuttonssharethesameconf_key.
"active":describedabove.
"radio":thevalueofconf_keywhenthebuttonisenabled.Soforinstance3
buttonslow/med/highwouldhave"radio"valuesof0,1,2.
"enabled":only1oftheradiobuttonssharingthesameconf_keywilleverbe
enabledatatime.Thisisusedtoplayananimationmakingtheenabledoption
standout.
"conf_key":togglethisoption,GameLogic.globalDict['conf'][conf_key]will
besettothe"radio"valueofthebuttonthatsenabled.
Noe,Thieampleomikebindingconfigaioninceiifailcomplicaedand
pecificoYoFankie.
Logic Details
Frankies Logic
Overview
Frankie'sbehaviourismadefromanumberofobjectswithaninvisibleparentthat
doesalmostallthelogic.Thelogicbricksaredividedintomanageablestates(walk,
run,fall,idleetc)soeachstatecanbeeditedwithoutdealingwiththelogicfrom
otherstates.
Thereare2mainexceptionstothisrule,status(15)action(16)soFrankiecan
executeactionsandhislifeismaintainedthroughoutgameplay.
Sensorlogicbricksdetect...
userinput(keyboardorjoystick)
collisionswithspeciallevelelements(eg.lava,water,bounce,portal).
propertychangestohealthandinventory.
Actuatorsareusedto...
playanimationsandsounds
enternewstates
setpropertiesforhealth,carryingandtimers.
applyphysicsforces(eg.jumpingandrunning)
constrainorientation(eg.walkupright,rungroundparallel,glidelimit
pitch).
Scriptsareneededforadvancedfunctionalitylike...
gliding,whereFrankie'spitchinfluencesspeedanddecent.
hangingoffaledge,whereraysarecasttodetectthetopoftheledgesetting
Frankie'sverticalposition.
Contextsensitiveactionsthattestsurroundingsforenemies,whatFrankie's
carryingandhisinventory.
Frankie's States
idle (1)stateisthedefaultstatewhenFrankieisonthegroundandnotdoing
anything.
walk (2)whenholdingforwardorbackwards.
servomotionactuatortomaintainconstantspeed.
run (3)whenholdingdownactionkeyandforward.
linearvelocityonlyisusedtomoveFrankieforward.
adistanceconstraintactuatorwiththerotationoptionenabledisusedto
keepFrankierunningparalleltothesurfaceoftheground(makingloop
theloopspossible)
runspeediscontrolledfromathe"frank_run_speed"script,thatadjusts
therunspeedbasedonthe"boosted"propertyandFrankie'spitch(to
acceleratearoundalooptheloop).
fall (4)stateissetwhenFrankieisnotcollidingwithanygroundobjectsand
immediatelyafterjumping.
Frankieisconstrainedtobeinguprightwhilefallingusingorientation
constraintactuator.
FromthisstateFrankiecanalsobounceorchangestatesbylandingon
anotherplayertobecarried,grabontoaledgeorglidebyholdingdown
jump.
ledge hang (5)statecontinuouslykeepsFrankieattachedtoanedgewhere
Frankiecanshimmyfromsidetoside,dropofforclimbifthereisground
abovetheledge.
Thisisoneofthefewstateswhereactionsaredisabled(state16)
dynamicsarenotsuspended,thepythonscriptkeepsFrankieattachedto
theedge.
carried (6)whenFrankie's"carried"propertyisnonzero,thisstateisset,
almostallfunctionalityisdisabledandFrankiecanonlythrowobjects.
idle animation (8)whenidleforawhilethisstateisadded,using
"frank_random_anim"scripttoplayarandomanimationactuator.
Thisstatediffersfromothersbecauseit'saddedontopofanotherstate.
Sincethisstateonlyplaysananimationitdoesn'tmatterifit'sdisabled
byanotherstatebeingset,suchaswalkingorfalling.
death (11)issetwhenFrankie'slifeiszero,thisstatewillimmediatelyswitch
tostate12or27ifthereislavacollision.
death ground (12)playsthedeathanimationthensetsrespawnstate26.This
stateissetexclusively,disablingallplayerinput.
stats (15)updatesFrankie'shealth,reactstobeinghit,touchingwater,collects
pickups,activatesportalsandsendsmessagestotheheadsupdisplay(HUD)
overlayscene.
Thisstatewillrunmostofthetime,inallotherstateswhereFrankiehas
freemovement(notdeath,drownorrespawn).
actions (16)statedetectsinputandperformsactionsacombinationof
playinganimationsandperformingactionlogic.Thelogicforcatchingand
checkingifFrankieisonthegroundornotisalsodoneinthisstate.
the"frank_action_all"scriptsenseskeyinput,checkswhatthereisto
kickorthrowthensetsthe"action_name"propertyandplaysthe
animation.Thiskeepsthescriptrunningwhile"action_name"isset.
Runningthelogiconkeypresswouldbesimplebutnotveryconvincing,
sothescripthasaframesetforeachactiontoexecutelogic,afterthe
frameinthearmatureanimationandthe"action_done"propertyisset.
Youcanaddyourownactionsbyaddingakeysensor,actionactuator
andfollowingtheconventionsin"frank_action_all"script.
thisstatealsorunsalongsidemostotherstates(aswithstate15),
howeverit'sdisabledduringledgegrabandledgeclimb.
jump init (18)stateplaysasound,setsthelinearvelocityandresetsthe
"jump_timer"and"grounded"property.
Aftersettingthepropertiesweimmediatelyswitchtothefallstate.This
isdonebecausehavingalljumpactuatorsattachedtocontrollersinidle,
walkandrunstateswouldbehardtomaintain.
glide (19)stateisenabledbyholdingjumpwhilefalling.Alloftheglidelogic
isperformedinthe"frank_glide"scriptwhichdealswiththedynamicsof
speedandpitchtoenableswoopingandremainingairborneforashorttime.
ledge climb (20)isusedwhenpressingforwardwhilehangingonaledge.
AnanimationplayswhileFrankiemovesupontotheledgeabove.
ServomotionactuatorsmoveFrankieupandforwardatafixedspeed
withouthavingtosuspenddynamics.
Themotionactuatorsaresynchronizedwiththeanimationusingdelay
sensorstotimethechangeinmotionfromupwardtoforward.
stop idle animation (23)resetstheidleanimationtimeranddisablescamera
orbit,thendisablestheanimationstateanditsownstate.
respawn (26)resetsFrankie'slocationandrestoresalmostallhispropertiesto
theiroriginalvalues.
death lava (27)isthesameasdeathground,exceptadifferentanimationand
soundplay.
drown (28)stateissimilartothedeathstates,exceptinsteadofrespawning,
the"frank_drown_revive"scriptmovesfrankietothesecondlastlocation
wherehewastouchingtheground.
Frankie's Properties
idThisisauniqueplayerIDintegerforeachplayer,0or1forplayers1and2.
Thisisusedwheninitializingtheplayertosetkeykeyboardpreferencesand
splitscreen.
Whenyouthrowanobject,your"id"isassignedtoits"projectile_id"sowe
knowwholastthrewtheobject.
Startingas1,correctlyinitializedinthescript"frank_init"
groundedisusedbyalotofFrankie'slogicbricksandscriptstoknowifheis
onthegroundornot.Thisvalueismanagedbythe"frank_ground_test"script
(State16)wherea"ground"collisionandZraysensorareusedtodetectif
thegroundstatechanges.
Thispropertycouldberemovedandbereplacedwithgroundcollisionsensors
everywhere,howeveracollisionsensoralonecanjitteronbumpyterrain,the
combinationofground+raygivesbetterresults.
predatorisusedbysheep,ramandratlogictotellyou'reanenemyandto
attackorrunawayfromyou.
kickableisusedfor2playermodetoallowyoutokickeachother.Sheepand
ratsalsohavethis
property.
hitissetbyother
objectslogicwhen
you'reattacked(rats,
ramsorasecond
player)
Whenthisisset,
Frankie'slifeproperty
willhavethehitvalue
subtractedandthehit
valuesetbacktozero.
The"frank_health"
scriptrespondstonon
zerohitvalues.
Usingthismethod
makesaddinginyour
ownenemieseasier,
alltheyneedtodois
setthe"hit"valueof
theobjecttheyare
attacking.
orig_posstores
Frankie'sinitial
locationwhenentering
thelevel.When
Frankiediesthis
positionisusedfor
respawning.
Thisvalueis
initializedinthe
"frank_init"script.Itis
usedin
"frank_respawn"andasafallbacklocationin"frank_revive"scripts.
ground_posandground_pos_oldpropertiesareupdatedeverysecond,storing
thelastinstanceFrankiewasontheground.
Atthemomentthisisonlyusedforrevivingafterdrowning,whereFrankieis
revivedatthe(2nd)lastpointwherehetouchedtheground.
ground_pos_oldisalwaysasecondolderthenground_postomakesurethe
groundlocationusedisn'ttooclosetothewaterandsetimmediatelybefore
drowning.
Thesevaluesaresetinfrank_ground_pos
water_touch_timeSimplydrowningwhenFrankietouchesthewaterdoesn't
workwell,especiallyjumpingoffdrowningsheep.Thistimerisusedtomake
sureFrankieistouchingthewaterforashortperiodbeforeswitchingtothe
drowningstate.
(seewater_timersensorsandcontrollerinState15)
camera_orbitisanintegerusedtosetthecameraorbitingaroundFrankie
whenheplaysidleanimations,drownsorfallsinlava.
The"Camera_Scaler"objecthasasensorthatchecksthisproperty,runninga
motionactuatorwhenitsnonzeroandplaysanipowhenitsfalsetosetthe
rotationback.
See"Camera_scalers"orbit_onandorbit_offcontrollers.
idle_anim_triggerThistimerisusedtoplayidleanimationswhenFrankie
hasbeeninactiveforawhile.
Itisinitializedtoanegativenumberandwillorbitthecamera,thenaddthe
idleanimationstatearound0.0
SeelogicbickinSae1ihheidle_animpefi
carryingintegerissetto1whenFrankieiscarryingsomething.
ManyscriptsusethistocheckifFrankiecandoactionslikecollectitems,
tailwhip,doublejumpandrun.
Themainlogicsettingthisvalueisthe"frank_carry"scriptwhichruns
wheneveranobjectwiththe"carried"propertytouchesFrankie.
SeeSae16fank_caconolle.
carrieddefinesthisasanobjectthatcanbecarried(player1cancarryplayer
2forexample).Itsvalueisusedbyscriptsandlogicbrickstoknowifyouare
beingcarried.Whenthisisnonzerostate6issetwheredynamicsare
suspendedandFrankiecan'tdoverymuch(exceptthrowanythinghe'salready
carrying).
force_walktimerisusedwhenwewanttostopFrankiefromrunning,when
thetimerisbelowzerotherunstatewillswitchimmediatelybacktowalk.
Thisissettoalwaysbenegativewhencarryinganobject,andusedtoforce
walkingforashorttimewhenFrankieishit,throwing,kickingandtail
whipping.
action_nameisusedwhenFrankieperformsanactioncurrentlyitsvalue
willbeeither"throw_carry","throw","kick"or"tailwhip".Thismeanswe
knowwhatactioniscurrentlyrunningandalsostopsmultipleactionsfrom
runningatonce.
Oncefinishedthevaluewillbesettoanemptystring.
Seeae16heehe"fank_acion_all"cipiedoconolallhe
acion
action_doneisusedbythe"frank_action_all"scripttocheckifthefunction
associatedwithanactionhasrunyet.
Withoutthis,actionscouldnottakeplaceinthemiddleofananimation.
Seeae16alo
throw_itemstorestheitemFrankiewillthrownext.Ifthereweremore
collectibleitemsthathaddifferentpurposes,thiscouldbeusedtocycle
throughactiveitems.
See"fank_ene_pickp"cipinae15heehelacollecedieme
he"ho_iem"and"fank_acion_all"inSae16heehe"ho_iem"
defineheiemohone
lifeforstoringFrankie'scurrenthealthandforupdatingtheHUDmeter.
Seehe"fank_healh"cipinSae15
life_maxFrankie'smaximumhealthvaluetolimithowmuchlifeFrankiecan
pickup.
See"fankie_ene_pickp"inSae15
revive_timeissettozerowhenFrankieishit,anotherhitwontbeapplied
until"revive_time"isover1.0
See"fank_healh"cipfomae15
jump_timetimerissetto0.0uponjumping,whereitisusedtoignoreany
groundcollisionsforashorttimeandthentodetectifit'stoolatetodoa
doublejump.
jumptimeisalsoreusedfortimingtheglideduration.
See"fank_gond_e"onSae16andSae18heehejmpaleae
e
double_jumpisusedtocheckifFrankiehasdoublejumped(sinceyoucan
onlydoublejumponce)
See"fank_fall"cipinSae4.
glide_z_initissettoFrankie'sZaxiswhenhestartsgliding,itsusedtomake
surehecanneverglidetoahigherlevelthenwhenhestarts.
Seehe"fank_glide"cipinSae19
run_wall_timerisusedsoFrankiecanflipoffawallwhenherunsintoany
wallwiththe"slip"property.
See"fank_all_n"cipinSae3
boostedissetsetwhenFrankiecatchesabutterfly(touchesapickupwitha
"boost"property),makinghiscolourflashrunalotfaster.
See"fank_n_peed"cipinSae3,"fank_ene_pickp"heeheboo
aleie
can_climbissetwhenhangingbycastingarayabovetheledgetodetectif
thereisanygroundforFrankietoclimbonto.
Ifthisisnotzero,pressingupwhilehangingwillmakeFrankieclimbuponto
theledge.
See"fank_ledge_hang"cipinSae5
ledge_regrip_timerisusedwhendroppingfromaledge(downkeywhile
hanging)tostopFrankiefromgrabbingtheledgeimmediatelyafterdropping.
Seehe"fank_ledge_collide"cipinSae4
Level Design Physics/Logic
Settingupaleveltorunwithfrankieslogiciseasytostartwith,justmakesureany
areayouwanttostandonhasthe"ground"property.
Fromhereyoucanplaythelevel,you'llprobablynoticeglitchesbutthesecanbe
dealtwithbyfinetuningthelevel,(seenotesbelow).
Physics Objects
Thecurrentmethodofdefininggroundandbarriersislimitedinthatitrequiresyou
tohaveseparateobjectsforeach.
FortheYoFrankielevelsitwaseasiertoremovecollisionsfromthesceneryand
addinvisiblephysicsobjects.
Physicscanbedisabledforsceneryinthegamelogicbuttons.
Physicsonlyobjectscanhavetheirrenderoptionturnedoffintheoutlinersothey
areinitializedinvisible(savesaddingUV'sandusingtheinvisibleoption).
Materials
Wallsandotherverticalsurfacesyoudontwanttorunupshouldhaveamaterial
withnofriction(SeethematerialsDYNbutton).
Properties
ThesepropertiesarecheckedforinFrankieandotherentitieslogic,sothecharacters
interactcorrectlywiththelevel.
groundpropertyisusedtodefineanythingFrankiecanstandon.These
surfacesdon'thavetobeflat(alooptheloopforinstancehasthe"ground"
property).Howevermakesurethisisn'tassignedtowallsandbarriers.
Noe,plafomojmpponoholdbeondedbabaieha
doen'haehe"gond"pope,Theopholdbeoeabo0.05o
colliionihheopofhebaieon'alocollideihhegond,
oheieFankieillaalkingbefoeheionopofheplafom.
slipwallpropertymakesbackflipsoffwallspossiblewhenrundirectlyinto.
RunningatthewallfromananglewillcauseFrankietorunparalleltothe
wall.
Thisisn'tnecessaryforgameplaytoworkbutmakesrunningaroundalevel
feelsmoother.
Thealeofhipopein'ed.
ledgepropertyisusedtodefineareasthatFrankiecanhang.on.
Thealeofhipopein'ed.
Theseshouldbeverticalstrips0.45deep.
Ghostcollisionoptioncanbeusedifyouwanttobeabletoungripand
fallthroughtheledgegrabgeometry(withbranchesforexample).
bouncepropertywillmaketheobjectbounceFrankiebackupintheairwhen
hefallsontoit.
Thealeofhipopein'ed.
killpropertywillmakeFrankieloseasmanylivesasthekillvaluewhich
mustbeaninteger.
waterpropertyshouldbeappliedtothesurfaceofariversoFrankiedrowns
whentouchingitforashorttime.
Noehiobjecholdbeagho
Thealeofhipopein'ed.
lavasimilartowater,justplaysadifferentanimationforFrankie.
liquidthispropertyshouldbeappliedtowaterorlavaobjectssopickupswill
disappearwhentouchingthem.
Thealeofhipopein'ed.
Retrievedfrom
"http://wiki.blender.org/index.php/Org:Institute/Open_projects/Apricot/BGELogic"
Contents
1BlenderGameEngineLogic
1.1Overview
1.2LogicSharing
1.3States
2LogicElements
2.1FrankiesCamera
2.1.1Notes
2.2Frankie'sStates(Simplified)
2.2.1Keys
2.2.2LevelProperties
2.2.3States
2.3LevelPortals
2.4Splashing
2.52PlayerSplitScreen
2.6Menu
2.6.1Implementation
2.6.2ItemActivationTypes
2.6.2.1trigger
2.6.3portal
2.6.4Configuration
2.6.5Toggle(configuration)
2.6.6Radio(configuration)
3LogicDetails
3.1FrankiesLogic
3.1.1Overview
3.1.2Frankie'sStates
3.1.3Frankie'sProperties
3.2LevelDesignPhysics/Logic
3.2.1PhysicsObjects
3.2.2Materials
3.2.3Properties
qicksearch...
2.6
UnversionedUnv
AllBlenderseriesAll
Blender2.42.4
Blender2.52.5
Blender2.62.6
EN
Arabicar
Bulgarianbg
Catalanca
Czechcz
Germande
Danishdk
Englishen
Greekel
Spanishes
Farsifa
Finnishfi
Frenchfr
Indonesianid
Italianit
Japaneseja
Koreanko
Lithuanianlt
Macedonianmk
Mongolianmn
Dutchnl
Polishpl
Portuguesept
Romanianro
Russianru
Serbiansr
Swedishsv
Thaith
Turkishtr
Ukrainianuk
Chinesezh
Wiki
Reportawikibug
WikiGuidelines
Specialpages
Categories
Popularpages
Newfiles
Newpages
Recentchanges

Вам также может понравиться