level design quake army knife (quark): – csg & bsps – quark/ quark/ milkshape 3d –...

Post on 11-Jan-2016

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Level DesignLevel Design

Quake Army Knife (QuArK):– CSG & BSPs– http://dynamic.gamespy.com/~quark/

MilkShape 3D – low-polygon modeler initially designed for

Half-Life. During development, many file formats were added.

Game EnginesGame Engines

Objects and LevelsScripting

User interaction and gameplay: User interaction and gameplay:

Scripting, AI, Physics, and BehaviorsScripting, AI, Physics, and Behaviors How are Players and NPCs controlled?

– Player’s interface– Scripting, AI, Physics, Behaviors

Determines gameplay

User InterfaceUser Interface

Manual (hardware)– Keyboard, mouse– Controller: analog mini-sticks, D-pad, analog buttons

Visual (screen display)– Active: menus, actions– Passive: status, HUDS– Score, lives, power, map, etc.– Split-screen, Whole screen, Invisible

User Interface:User Interface:UnrealUnreal

Controllers are non-physical actors which can be attached to a pawn to control its actions. – PlayerControllers are used by human players to control

pawns – AIControllers are used to implement the artificial

intelligence for the pawns they control. AIScripts can be associated with pawns placed in levels to modify

their AIControllers.

– ScriptedControllers can be used to make a pawn follow a scripted sequence

HUD– Uses 2D Canvas

User Interface:User Interface:VRML/X3DVRML/X3D

Sensor Nodes:– Drag Sensors:

TouchSensor, SphereSensor, PlaneSensor, etc.

– Proximity Sensor– Visibility Sensor

HUD Prototype– Moves 3D object along with viewpoint

ScriptingScripting

Native support the major concepts of time, state, properties, and networking (replication) which traditional programming languages don't address.

Safety– a pointerless environment with automatic garbage

collection – a safe client-side execution "sandbox

To enable rich, high level programming in terms of game objects and interactions rather than bits and pixels.

ScriptingScripting

Slow– C++ : 50M base language instructions per

second– UnrealScript: 2.5 million - a 20X performance

hit.

create animation-driven or time-driven code – Exploit latent functions (like FinishAnim and

Sleep)

Scripting: TimeScripting: Time

Most engines use Ticks– smallest unit of time in which all actors in a level are

updated. A tick typically takes between 1/100th to 1/10th of a second.

– limited only by CPU power; the faster machine, the lower the tick duration is.

Synchronous vs. Asynchronous Zero-time vs. Latent Event cascade

Scripting Examples: Scripting Examples: UnrealScriptUnrealScript

Actor (extends Object) is the parent class of all standalone game objects in Unreal. – The Actor class contains all of the functionality needed

for an actor to move around, interact with other actors, affect the environment, and do other useful game-related things.

Pawn (extends Actor) is the parent class of all creatures and players in Unreal which are capable of high-level AI and player controls.

Scripting Examples:Scripting Examples: UnrealScriptUnrealScript

function ModifyPlayer(Pawn Other) { local xPawn x; //x is a variable x = xPawn(Other); if (x != None) { x.MaxMultiJump = MultiJumpCount; x.MultiJumpBoost = MultiJumpBoost; x.Health = StartingHealth; x.HealthMax = MaximumHealth x.SuperHealthMax = SuperDuberMaximumHealth } }

Scripting Functionality: Scripting Functionality: World AwarenessWorld Awareness

native final function Actor Trace(HitLocation, HitNormal, TraceEnd, TraceStart, bTraceActors, Extent, Material) – casts a ray (aka "traces") into the world and returns what it

collides with first. Trace takes into account both this actor's collision properties and the collision properties of the objects Trace may hit.

Use Trigger– If a human controlled pawn is within the proximity of this

trigger and hits their USE key, it activates this trigger. VRML: Proximity, Collision, Gravity, Visibility nodes

Scripting Examples: Scripting Examples: Unreal Animation BlendingUnreal Animation Blending

Multiple animation channels/stages are used to blend into the animation track.

native final function AnimBlendParams( int Stage, BlendAlpha, InTime, OutTime, BoneName) – Before playing animation on any channel, you need to call

AnimBlendParams to set up that channel. Channels are blended in order starting at the base channel (channel 0) with higher channels blended on top.

– animations played on higher channels will mask animations played on lower channels, depending on the BlendAlpha of the higher animation channel and which bones the higher channel affects. 

Scripting Examples: Scripting Examples: VRML Character ControlVRML Character Control

function mouseinput(val,t){

newrot.angle=calcangle(val.x,val.y);

touchval=val;

mlen=val.length();

if (mlen)

body2.rotation=newrot;

loco(mlen,t);

}

Scripting Examples:Scripting Examples: VRMLVRML

function keyinput(k,t){ if (k==106){ //jump stand.stopTime=walk.stopTime=run.stopTime=

jump.startTime=t; mlen=0; } if (k==119){ //w - walk mlen=1.5; } if (k==114){ //r- run mlen=2.9; }

if (k==104){ //h- halt mlen=0; }

Scripting Examples: Scripting Examples: VRMLVRML

if (k==38){ //up - faster mlen+= .2; } if (k==40){ //down - slower mlen-= .2; } if (k==39){ //right - turn newrot.angle= newrot.angle - .39; //16th of turn body2.rotation=newrot; } if (k==37){ //left- turn newrot.angle= newrot.angle + .39; body2.rotation=newrot; }

Scripting Examples: Scripting Examples: VRMLVRML

if (mlen<0) mlen=0;

touchval.x= mlen * Math.sin(newrot.angle);

touchval.y= mlen * Math.cos(-newrot.angle);

//print('ang='+newrot.angle);

//print('x='+touchval.x+',y='+touchval.y);

//print('mlen='+mlen);

loco(mlen,t);

}

Scripting Examples:Scripting Examples: VRMLVRML

function loco(mlen,t){ if (mlen<0.4){ //print('STOP'); stand.startTime=t; walk.stopTime=t; run.stopTime=t; }else if (mlen<2.9){ //print('WALK'); stand.stopTime=t; walk.startTime=t; run.stopTime=t; walk.cycleInterval = 4 - (1.0 * mlen); }else{ // print('RUN'); stand.stopTime=t; walk.stopTime=t; run.startTime=t; run.cycleInterval = 0.80 + (2.0/(mlen-1.9)); }}

Scripting Examples: Scripting Examples: VRMLVRML

function engine(val,time){ //advance position each frame

if (lasttime){

if (touchval.length()>=0.4) //not stopped

body.translation=

body.translation.add(touchval.multiply((time-

lasttime)*.5));

}

lastval=t;

}

Artificial IntelligenceArtificial Intelligence

Strong AI: the ability to perform activities normally thought to require intelligence, learning, and adapting.

Weak AI: specialized intelligent qualities.Deterministic- predictable

– Path PlanningNondeterministic – uncertainty

– NPC learning to adapt to fighting tactics

Artificial IntelligenceArtificial Intelligence

Chasing and Evading & Pattern movement Flocking Pathfinding

– A* algorithm Logic: Finite State Machines, Fuzzy Logic Probability

– Bayesian Adaptive

– Neural Networks– Genetic Algorithms

Artificial Intelligence:Artificial Intelligence:UnrealUnreal

AI Scripting allows enemies (and friends) to be controlled easily via external files that can be easily changed without map rebuilding.

Almost every important NPC (non player character) in Unreal II has a long and detailed script behind it controlling its behavious and actions under various conditions

Artificial Intelligence:Artificial Intelligence:UnrealUnreal

:MarinePatrolontrigger ChangeMarinePatrol gotolabel MarinePatrol2gotoactor PathNode0gotoactor PathNode1sleep 2gotolabel MarinePatrol

:MarinePatrol2ontrigger ChangeMarinePatrol gotolabel MarinePatrolgotoactor PathNode2gotoactor PathNode3sleep 2gotolabel MarinePatrol2

Artificial Intelligence:Artificial Intelligence:TorqueTorque

function MyBot::onReachDestination( %this, %obj ){

// Moves to the next node on the path.if( %obj.path !$= "" ){

if( %obj.currentNode == %obj.targetNode )%this.onEndOfPath( %obj, %obj.path );

else%obj.moveToNextNode();

}else

echo( "MyBot::onReachDestination warning - Path is blank!" );}

function MyBot::onEndOfPath( %this, %obj, %path ){

%obj.nextTask();}

PhysicsPhysics

Collisions, gravity, falling, explosions, etc.– should be used selectively in your level so as not to

overwhelm the engine.

 NOTE: Don’t confuse with: PYSICS-BASED ANIMATION

– the motion of the pawn determines what animation the pawn is playing.

– good for multiplayer situations because each client just looks at the motion of a given pawn to see what animation should be playing; no extra information needs to be transmitted.

Physics-based AnimationPhysics-based Animation

walking, running, crouch walking, swimming, flying, jumping, falling, landing, and idling.

functionality for playing arbitrary animations not based on movement.

Physics-based Animation:Physics-based Animation:UnrealUnreal

// Play appropriate idle animationssimulated function PlayWaiting(){ if (Physics == PHYS_Falling) LoopAnim(FallingAnim, 1.0, 0.2); else if (Physics == PHYS_Flying) LoopAnim(FlyIdle, 1.0, 0.2); else if (Physics == PHYS_Swimming) LoopAnim(SwimIdle, 1.0, 0.2); else { if (bIsCrouched) LoopAnim(CrouchIdle, 1.0, 0.2); else LoopAnim(StandIdle, 1.0, 0.2); }}

Physics-Based AnimationPhysics-Based Animation3D GameStudio3D GameStudio

Function PlayerAnim(){

While(1){ ent_animate(my, null, 0, 0); If(my.SKL_movement_mode == MOV_running){ // RUNNING ent_animate(my,ANI_seq_run_lower,my.SKL_ani_frame,anm_cycle); if (ANI_attacking > 0){ if (attack_toggle_left){ ent_animate(my, ANI_seq_ground_punch_left,

my.SKL_ani_attack, anm_add); }else{ ent_animate(my, ANI_seq_ground_punch_right,

my.SKL_animation_attack, anm_add); }

}else{ ent_animate(my, ANI_seq_run_upper, my.SKL_ani_frame,

anm_cycle+anm_add);}

}}

top related