Presentation is loading. Please wait.

Presentation is loading. Please wait.

Artificial Intelligence in Game Design Camera Control.

Similar presentations


Presentation on theme: "Artificial Intelligence in Game Design Camera Control."— Presentation transcript:

1 Artificial Intelligence in Game Design Camera Control

2 The Camera as a NPC Good camera placement vital to good gameplay! –Must maintain clear view of selected character –Must highlight significant events to the player –Must anticipate player movements, providing clear view of where the player’s character is moving Best approach: Treat like an intelligent character –Must move in logical ways to perform goals Movement must be smooth, not “jerky” or discontinuous –Best actions often depend on state of game

3 Categories of Camera Perspective First person : From perspective of player’s character –Implemented by parenting camera to “head” of character –Few AI-related problems, since camera totally controlled by player

4 Categories of Camera Perspective Third person: From point of view of “user” observing world and its inhabitants –Often “birds eye” view showing world around character –Few AI-related problems, since camera usually fixed above player

5 Categories of Camera Perspective “First and a half person” –From POV slightly behind and to side of player –Combines character POV with view of character

6 “First and a Half” Person Usually implemented by parenting camera to position relative to player character –Maintains same relative position/angle to player as player moves

7 Problems Must make sure no obstacles between camera and character –Will have to move camera around obstacles to keep character visible Must make sure camera shot includes all relevant characters –Current opponent NPCs –Player themselves!

8 Camera Position Selection Usually have many viable camera positions for first-and- a-half person perspective Choose the “best” one based on current situation

9 Raycast Method Project “rays” in different directions from character relative to camera angle (x angle, y angle ) –(x angle + Θ, y angle ) –(x angle - Θ, y angle ) –(x angle, y angle + Θ) –(x angle, y angle - Θ)

10 Raycast Method Use raycasting to see if any intersect an obstacle at distance shorter than distance from camera to character These are potential situations where camera may be blocked in future depending on how character moves Example: Vector B intersects obstacle

11 Raycast Method Camera should flee vectors that are potential problems –Change relative angle –Potentially change distance/height –Should arrive at original angle once obstacle cleared

12 Multipoint Method Generate points in region where camera is moving to Evaluate suitability of each point Move camera to most suitable point

13 Defining “Suitability” Primarily based on constraints on relative position to character –Distance constraint: Penalty proportional to how far camera is from desired distance to character –Height constraint: Penalty proportional to how far camera is from desired height relative to character –Orientation constraint: Penalty proportional to how far camera is from desired angle relative to character

14 Defining “Suitability” Collision detection and visibility constraints –0 if all characters visible –1 if main character not visible Possibly defined as “more than half of torso/head occluded” –0 < n ≤ 1 based on degree to which other important characters in area of player not visible

15 Defining “Suitability” Different components usually weighted Suitability = W D distance constraint + W H height constraint + W O orientation constraint + W v visibility constraint + (W v usually larger than others) Key idea: Developers can “tune” weights –Can experiment with different values by playing game –Which give most “intuitive” camera behavior?

16 Regional Constraints May want to constrain camera to specific area in space –Example: Showing dialog between two characters should keep camera locked in torus around the characters Points to search limited to those that fall within this region

17 Smoothing Potential problem: Several nearby points might have similar suitability measures Camera may oscillate back and forth between them as character moves –“Jerky camera” appearance

18 Smoothing Apply smoothing (averaging) to suitability function Suitability (x, y) = 0.5 * Suitability (x, y) + 0.125 * Suitability (x+1, y) + 0.125 * Suitability (x-1, y) + 0.125 * Suitability (x, y+1) + 0.125 * Suitability (x, y-1) + Usually results in one point consistently best over period of time

19 State-based Suitability Different constraint weights best in different game situations –Driving: Fixed angle relative to player most important –Jumping: Correct height most important to keep player from jumping out of camera –Multicharacter battle: Keeping all characters in frame

20 State-based Suitability Can use finite state machine for camera to choose appropriate weights/constraints Walking constraints Jumping constraints Area with pits Driving constraints Car reached

21 Multicharacter Games Some games allow player to swap control between several different characters –Camera must show world from perspective of current character –Transition should be smooth to avoid player confusion Don’t just jump

22 Multicharacter Games Move camera to new character in smooth transition May have to use steering behaviors –Arrive at position behind next player character –Flee obstacles, positions where character not visible

23 Multicharacter Games Best approach may be to move over obstacles –Temporarily take “third person” approach

24 Camera Events Camera must often respond to other game events –Example: Off-screen explosion should cause “camera shaking” Camera must be part of game messaging system –List of current world events maintained –Camera must regularly poll list for relevant events, take appropriate action EventState explosiontrue …… Game Engine


Download ppt "Artificial Intelligence in Game Design Camera Control."

Similar presentations


Ads by Google