Download presentation
Presentation is loading. Please wait.
1
Behavioral animation CSE 3541 Matt Boggus
2
Material recap and trajectory
Geometric Artist specifies translation and rotation over time Physically based Artist specifies forces acting on objects Motion equations dictate movement Behavioral Artist directs autonomous agents Interpolation Artist draws the scene at the beginning and end of an interval of time Intermediate positions are calculated
3
Behavioral Animation Control the motion of one or more objects using virtual actors Goal: realistic or believable motion so that the object appears to be autonomous Matt Lewis’ page on BA Example videos 1 + 5
4
Actor properties (position only)
Goal (xg, yg) V = Goal - Position Force based Next Position = Position + V * dt Position (x, y)
5
Problems with repulsive forces
6
A hierarchy of motion behaviors
Action selection State logic Reflex agent Steering Position and orientation changing logic Locomotion Figure animation covered later in 3541 Keep using primitive shapes or non-animated meshes Figure source: Steering Behaviors For Autonomous Characters
7
Reflex agent Figure source:
8
Reflex agent – predator
9
Actor properties (position and orientation)
Orientation (ox, oy) = transform.forward Rotate(θ) Determine which rotation (±θ) orients the actor closer to the goal using dot product Rotate(-θ) Goal (xg, yg) Vtarget = Goal - Position Steering based Position (x, y) In Unity, you can use RotateTowards()
10
Orientation vectors in Unity
Image Image source:
11
Sample starter code class OrientedAgent2D { // Data GameObject model; // Use this field for geometry, // position, and orientation // Methods Update(float deltaTime); TurnLeft(); TurnRight(); MoveForward(); MoveBackward(); }; For an agent moving in the x-z plane, its y position is and y component of transform.forward are both always zero
12
Behavioral animation Character or object motion based on:
Knowledge of the environment Aggregate behavior Primitive behavior (Intelligent behavior) (Crowd management)
13
Knowing the environment
Vision and other senses Information available from the current state of the scene Computed “fresh” each Update() Memory Information stored from the past Ex: lastKnownPlayerPosition field set at the end of an Update call where an enemy ai saw the player
14
Lab4 design note Predator class/objects/script must be able to access prey class/objects/script in order to get position for vision test Multiple options All objects are fields in one script Or, add methods that pass/take references to other objects or find objects by name
15
Vision Targeted vision General vision
Can the actor see object X? Boolean CanSee(object X); General vision What is everything the actor can currently see? Brute force approach: loop over all objects, use targeted vision on each one, return arrayList of GameObjects “seen” Possible computation/accuracy tradeoff How much of an object needs to be seen to be identified? Do we need to model visual perception?
16
Omniscience Everything in the scene is known
CanSee(object X) { return true };
17
Distance limited omniscience
18
Field of view
19
Field of view – example Orientation Vector (O)
Vector from agent to vertex (V) The dot product logic doesn’t take into account occlusion. Remember to normalize V before doing dot product. If the agent cannot see far away, also check that the magnitude of the V vector doesn’t exceed the max distance it can see. Angle of cone = θ Inside the cone when the angle between O and V is less then or equal to θ/2
20
Field of view – sample code
Vector3 agentPosition, orientation, objectPosition; float visionLimit; Vector3 agentToVertex = objectPosition – agentPosition; agentToVertex.Normalize(); if(Vector3.Dot(agentToVertex,orientation) > visionLimit) // objectPosition is in cone
21
Occluded Vision Ray casting with collision detection
Sample the environment
22
How well can the actor see X?
Target-testing vision (per object) How well can the actor see X? Use multiple rays Can the actor see X? Cast a ray
23
Target-testing vision (alternative)
Sample the vision cone Cast multiple rays
24
Other senses Hearing Smell Sensors & signal propagation
Spatial occupancy approach Applications
25
Spatial Occupancy
26
Memory What is recorded about the environment Spatial occupancy
Transience of objects: time-stamps Memory hierarchy: short-term, long-term
27
Behavioral animation Character or object motion based on:
Knowledge of the environment Aggregate behavior Primitive behavior Predator-Prey forces and movement Predator-Prey steering Intelligent behavior Crowd management
28
Lab4 – predator-prey simulation
Unbalanced abilities Vision Distance Field of view Linear speed (moving forward) Angular or rotational speed (turning) (For stealth game concept, consider enemy AI agents as predators, player controls prey)
29
Predator Prey vision anatomy
30
Prey-Predator (vision)
31
Prey-Predator (movement – speed and turning)
32
Motion – force based Force = c * posprey - pospred
Apply a force on the predator towards the prey when in view
33
Motion – kinematic based
vnew vold Determine the closest prey in view then turn towards it and increase forward velocity
34
Prey-Predator – environment forces
Using pure forces May not prevent object penetration Prey can be ‘hidden’ by environmental repulsive forces
35
Behavioral animation Character or object motion based on:
Knowledge of the environment Aggregate behavior Emergence Primitive behavior Intelligent behavior Crowd management
36
Aggregate Behavior: Emergent Behavior Type Elements Physics Env/Others
Typical qualities Type Elements Physics Env/Others Intelligence Particles Much/none None Flocking Some/some Limited Crowds Little/much Little-much
37
Emergent behavior Complex systems and patterns arising out of simple rules Aints – AI ants
38
Flocking, Swarming, Flying
Boids
39
Local control Rules defined to stay with friends, but avoid bumping into each other Need additional rules for collision avoidance with obstacles
40
Local information
41
Other flocking issues Global control Negotiating the motion
script flock leader global migratory urge Negotiating the motion Separation, alignment, and cohesion may compete/contradict Collision avoidance Once an object is in sight, start steering to avoid Splitting and rejoining (difficult) Collision avoidance too strong – flock may never rejoin after split Flock membership too strong – flock does not split and formation changes Modeling flight
42
Navigating using bounding sphere
43
Testing for being on a collision path with (bounding) sphere
Navigating Testing for being on a collision path with (bounding) sphere Given: P, V, C, r
44
Finding closest non-colliding point
Calculate s,t
45
Additional Slides, time permitting
46
Spatial Occupancy transiency doorway doorway wall
47
Negotiating the motion
Forces Or “Reasoning” (e.g. rule-based)
48
Modeling flight – common in flocking
49
Modeling flight Geometric flight – dynamic, incremental rigid transformation of an object moving along a tangent to a three dimensional curve
50
Less pressure above wing = lift
Modeling Flight – Lift Air passing above wing most travel longer than air below it. Less pressure above wing = lift
51
Modeling Flight – turn by rolling
52
Modeling Flight – summary
Turning is effected by horizontal lift Increasing pitch increases drag Increasing speed increases lift
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.