Gdc gameplay replication in acu with videos

Preview:

Citation preview

Gameplay and AI networking

in Assassin’s Creed Unity

Charles Lefebvre

AI programmer, Ubisoft Montreal

charles.lefebvre@ubisoft.com, @FrozenInMtl

Unity

Unity

Unity

Unity

Unity

glossary

Migration

Entity

Join in progress

Session Memento

NetObject

Master

Replica

Simulation bubble

PeerPeer to peer

Player

Multiplayer

Network keyDiscovery

Host

Components

Coop

NetObject

glossary

M

Peer 1 Visual component

AI component

Animation component

Network component

Network key

Entity

Network key (u64) = peer + type + ID

glossary

M R

Peer 1 Peer 2

Mementos

M

NetTokens

NetTokens: Layer for peer to peer conflict resolution

t=5

t=4

no

Peer1

yesPeer2 Peer3

t=4

t=5

yes

yes

NetTokens

Can also be used to wait for all players

t=5

t=4

Peer1

Peer2 Peer3

t=4

t=5

t=6

t=6

remote procedure call

Remote procedure call (RPC): execute a function on a peer, this function

will be executed on other peers

network void PlayAnimation(const AnimationParams & params);

• Can be ordered or not

• Can be persisted for Join In Progress

• Can be executed later, or re-executed

Flow examples:

remote procedure call

Replica Replica Replica

Master

Replica Replica

Master

Replica Replica

Master

NetHandle

struct NetHandle{

Handle<Entity> m_Entity;NetKey m_NetKey;

bool IsValid();Entity * GetEntity();bool GetPosition(vec4& position);bool GetSight(vec4& position);

}

NetHandle

?

NetHandle

(full entity)

??

?

Simulation

bubble

Undiscovered

entity

Spawning strategy

Spawning client

system

Spawning

request Spawning strategy

Spawning manager

Spawning strategy

Mementos

Peer 1 (spawner)

simulation bubble

M

replication

Net descriptor

Spawning

request

Spawning

requestR

replication

Peer 1

loading range

Peer 2

loading range

Spawning

request

Spawning

requestToken

M R

gameplay

• Replicate the crowd event generation in echo

• Replicate the victim/thief in engine

conclusions

(+) Almost no change in the spawning clients code

(+) Cheap in bandwidth

(+) Data is the same in single and multiplayer

(-) No network balancing

(-) A lot of edge cases to handle when a spawning request is cancelled

(-) Systemic gameplay is not easy to replicate

objectives

• Need a way to replicate the player’s movements with good accuracy

• Animation quality of replicas must be the same as masters

• Must support join in progress

• Shouldn’t take too much bandwidth

comparison tool

HSM

Animation

NetBehaviorAI

Replica

Replica Brain

flow

Controller

HSM

Animation

NetBehaviorAI

Master

Replication

Final decisions

final decisions

conclusions

(+) Good replication quality

(+) Can recover nicely from divergences

(-) Expensive in bandwidth

(-) 3 state machines (HSM / NetBehaviorAI / animation graph) to

maintained

• Replicate NPC behavior at a very low cost

objectives

• Not a perfect match: not a first person game

• Quality of realization: same for masters and replicas

• Existing behaviors easily updated to support multiplayer

flow

Logic

HSM

Animation

HSM

Animation

Intentions

Master

Intentions

Replica

Logic

Replication

replication

Animations Navigation Weapons LookAt

Idle IdleIdle Idle

Play animation

Push

Stumble

Go to position

Wander

Follow

Sheath

Unsheath

Fire

Look at

position

Look at

target

RPC

conclusions

(+) Cheap in bandwidth

(+) Seamless migrations

(-) Average replication quality

(-) Services (navigation, animation…) must also be synchronized to

prevent behavior branching

coordinators

• Spawn NPCs

• UI

• Interactions

coordinators

Sensors

Distance

Line of sight

UI

Coordinators in previous Assassin’s Creed games

Actions

coordinators

Net data

Sensors synthesis

Execution count

Local state

Released entities

For local player

Sensors

Distance

Line of sight

UI

Actions

R

M

M

coordinators

Replica

Net data

Sensors

synthesis

Sensors

Replica

Net data

Sensors

synthesis

Sensors

Master

Net data

Sensors

synthesis

RPCSensors

RPCRPC

MementoMemento

conclusions

(+) Good replication quality

(+) Cheap in bandwidth

(+) Code and data are the same in single and multiplayer

(-) Join in progress can be tricky

(-) Reaction times can become noticeable

stations

stations

How does it work in single player :

• Crowd Life Manager updates all stations

• Stations = data containers (not systemic)

• Stations loaded with cells

• NPCs spawned/released by stations

stations

• Amount of stations and NPCs to track

Challenges of replicating:

• Stations are not replicated

• NPCs in stations can be masters, replicas, or even non-

replicated entities

replication

replication

What to replicate ?

• NPCs

• Station state

Master = token winner

split mastering

Crowd Life

Manager

Stations

NPCs

Peer 1

NetObject

(master)

Peer 2

NetObject

(replica)

Peer 3

NetObject

(replica)

Peer 4

NetObject

(replica)

Crowd Life

Manager

Stations

NPCs

Peer 2

NetObject

(master)

Peer 1

NetObject

(replica)

Peer 3

NetObject

(replica)

Peer 4

NetObject

(replica)

Peer 1 Peer 2

Replication

s

Memento

Memento

conclusions

(+) Only 1 net object per peer = big gains on bandwidth/CPU

(+) Each peer can run their own logics

(+) Data is already available on discovery

(-) Data is broadcast on all peers even if they don’t need it

(-) Execution logic tends to be complicated

statsCurrent bps

stats

• Below TRC of 92 kbps per peer (around 30 kbps outside fight)

• Most expensive systems:

• Proxies: list of vectors

• Player, but high replication quality

• Crowd life: lots of stations, actually cheap per station

quality

conclusion

(+) Cheap in bandwidth, no additional CPU cost

(+) Good replication quality

(+) Multiplayer team = gameplay team

(-) Limited to a low number of players

(-) Hard to identify sources of divergences

conclusion

Existing code kept

and converted to

multiplayer