SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
Unity3D Scripting:
State Machine
Finite-State Machine
Definition:
This is a set of five elements:
(Σ, Q, s ∈ Q, T ⊂ Q, δ : Q x Σ → Q)
where Σ - the alphabet, Q - a set of states,
s - the initial (start) state, T - the set of
accepting states, δ - the transition function.
A graph with a finite number of states (nodes)
and a finite number of CMV transitions
(curves).
Two Questions
How this system would help us in
programming the game logic?
How this approach is better than others?
How To Use
Behavior of the game object may be
divided into a list of different actions:
Starting State
Target Searching
Attack
Death
Structure
Generalization
Any game component, whether a unit, or
a menu based or an abstract game as a
whole, which uses certain rules can be
programmed by using a state machine.
Advantages of State Machine
1. Divided, limited access to the context of state
2. Encapsulated logic for each state
3. Clarity, ability to upgrade code (source code
customization)
4. Reliability
Divided, Limited-Access Context State
Each state controls only its own context
and there is no need to check the set of
variables for other states
Logic Encapsulation for One State
This allows you to quickly respond to
errors that were found during testing, to
localize them and make changes. At the
same time this greatly reduced the
likelihood of introducing errors into
other states, because their context is not
available, and their logic is elsewhere.
Source Code Customization
Behavior of the object becomes more
classification-ruled and understandable.
Behavior modernization takes less time
and complexity associated with
modifications is greatly reduced.
Reliability
Transition from one state to another
occurs only in specific cases, to move
from one state to another if it was not
planned is not possible.
Property of C #: Operator: “Yield"
Operator: “Yield"
● "syntactic sugar"
● implement pattern: enumerator
Is being used for:
● implementing collection
● dividing the methods in several steps
Unity 3D - Specifications
We will use several features Unity3D:
● Operator yield and pattern enumerator.
● Call for one of the standard object methods
inherited from MonoBehaviour:
- Update
- FixedUpdate
- Start, etc.
Unity 3D - Specifications
We need the following entities:
● States
● Manager, which manages the transition
from one state to another
● Model - context of state machine, to
which the state will call to perform a
variety of actions.
State. Implementation Example
State. Description
No need to restrict the user with
inheritance. System is fairly
abstract, to restrict certain
properties of the state through the
interface.
States Manager: Implementation Example
States Manager: Explanation
Key methods:
● Set the initial state
● Infinite state that calls the logic
of the current status
● Cleanup
Infinite cycle. Implementation Example
Infinite Cycle. Clarification
● Possibility of correct completion
● Debug messages output
● Calling IState.Start (), IState.Cleanup (),
IState.DoWork () methods
● Switch state with the help of Field
NextGameState
IState.DoWork (). Implementation Example
Awaiting Something
Check one of the conditions, and if it does not
suffice you pass control higher up and go back
to check conditions at other times when the
manager would transfer control method.
This way you give a chance to any other logic to
be executed in a single game flow (GAME
THREAD), avoiding a whole bunch of problems
related to multithreading.
Methods
For any application, we need a method to invoke
the script cyclically inherited from
MonoBehaviour: Update, FixedUpdate,
LaterUpdate, etc.
Depending on the task you should choose the
right method and call it for update the state
machine.
Before you update the state machine it is
necessary to perform the initial state install. This
can be done easily in the Start or Awake
methods.
Model (context)
Often there is a need preserve some information
between the states was preserved some
information - the context of state machine. This
context could be a script that renews the state
machine. It is possible to store certain flags and
objects necessary for the states in this script.
Also, this context may contain links to game
resources and other game objects. So you pass
a reference from state to state to this script.
This approach will help to avoid a large number
of singletons in the game.

Más contenido relacionado

Destacado

Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Sperasoft
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmersNoam Gat
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unitydavidluzgouveia
 
게임 프레임워크의 아키텍쳐와 디자인 패턴
게임 프레임워크의 아키텍쳐와 디자인 패턴게임 프레임워크의 아키텍쳐와 디자인 패턴
게임 프레임워크의 아키텍쳐와 디자인 패턴MinGeun Park
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴예림 임
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameSarah Sexton
 

Destacado (12)

Unity 3d Basics
Unity 3d BasicsUnity 3d Basics
Unity 3d Basics
 
Securing PHP Applications
Securing PHP ApplicationsSecuring PHP Applications
Securing PHP Applications
 
Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks Code and Memory Optimisation Tricks
Code and Memory Optimisation Tricks
 
NYPF14 Report - CDA
NYPF14 Report - CDANYPF14 Report - CDA
NYPF14 Report - CDA
 
Unity introduction for programmers
Unity introduction for programmersUnity introduction for programmers
Unity introduction for programmers
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
 
Unity3D Programming
Unity3D ProgrammingUnity3D Programming
Unity3D Programming
 
Unity is strength presentation slides
Unity is strength presentation slidesUnity is strength presentation slides
Unity is strength presentation slides
 
게임 프레임워크의 아키텍쳐와 디자인 패턴
게임 프레임워크의 아키텍쳐와 디자인 패턴게임 프레임워크의 아키텍쳐와 디자인 패턴
게임 프레임워크의 아키텍쳐와 디자인 패턴
 
Unity presentation
Unity presentationUnity presentation
Unity presentation
 
게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴게임 개발에 자주 사용되는 디자인 패턴
게임 개발에 자주 사용되는 디자인 패턴
 
Introduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First GameIntroduction to Unity3D and Building your First Game
Introduction to Unity3D and Building your First Game
 

Similar a Unity3D Scripting: State Machine

Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana
Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq PermanaJetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana
Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq PermanaDicodingEvent
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetupAnton Kropp
 
[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in CapellaObeo
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System SimulationObeo
 
Microservices Architecture with Vortex — Part II
Microservices Architecture with Vortex — Part IIMicroservices Architecture with Vortex — Part II
Microservices Architecture with Vortex — Part IIAngelo Corsaro
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern ImplementationSteve Widom
 
Stateful streaming data pipelines
Stateful streaming data pipelinesStateful streaming data pipelines
Stateful streaming data pipelinesTimothy Farkas
 
Write better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtensionWrite better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtensionRodrigue Villetard
 
Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...
 Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ... Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...
Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...Big Data Spain
 
Scalability truths and serverless architectures
Scalability truths and serverless architecturesScalability truths and serverless architectures
Scalability truths and serverless architecturesRegunath B
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2NokiaAppForum
 
Introduction to simulation and modeling
Introduction to simulation and modelingIntroduction to simulation and modeling
Introduction to simulation and modelingantim19
 
State Pattern In Flex
State Pattern In FlexState Pattern In Flex
State Pattern In Flextcab22
 
Traffic Simulator
Traffic SimulatorTraffic Simulator
Traffic Simulatorgystell
 
Towards Rapid Implementation of Adaptive Robotic Systems
Towards Rapid Implementation of Adaptive Robotic SystemsTowards Rapid Implementation of Adaptive Robotic Systems
Towards Rapid Implementation of Adaptive Robotic SystemsMeshDynamics
 
Formal Verification of Distributed Checkpointing Using Event-B
Formal Verification of Distributed Checkpointing Using Event-BFormal Verification of Distributed Checkpointing Using Event-B
Formal Verification of Distributed Checkpointing Using Event-Bijcsit
 

Similar a Unity3D Scripting: State Machine (20)

Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana
Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq PermanaJetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana
Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
 
[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System Simulation
 
Microservices Architecture with Vortex — Part II
Microservices Architecture with Vortex — Part IIMicroservices Architecture with Vortex — Part II
Microservices Architecture with Vortex — Part II
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern Implementation
 
Stateful streaming data pipelines
Stateful streaming data pipelinesStateful streaming data pipelines
Stateful streaming data pipelines
 
L0537075
L0537075L0537075
L0537075
 
Write better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtensionWrite better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtension
 
Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...
 Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ... Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...
Dataflows: The abstraction that powers Big Data by Raul Castro Fernandez at ...
 
Clone cloud
Clone cloudClone cloud
Clone cloud
 
Scalability truths and serverless architectures
Scalability truths and serverless architecturesScalability truths and serverless architectures
Scalability truths and serverless architectures
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 
Introduction to simulation and modeling
Introduction to simulation and modelingIntroduction to simulation and modeling
Introduction to simulation and modeling
 
Trixboxguide
TrixboxguideTrixboxguide
Trixboxguide
 
State Pattern In Flex
State Pattern In FlexState Pattern In Flex
State Pattern In Flex
 
Traffic Simulator
Traffic SimulatorTraffic Simulator
Traffic Simulator
 
Towards Rapid Implementation of Adaptive Robotic Systems
Towards Rapid Implementation of Adaptive Robotic SystemsTowards Rapid Implementation of Adaptive Robotic Systems
Towards Rapid Implementation of Adaptive Robotic Systems
 
Formal Verification of Distributed Checkpointing Using Event-B
Formal Verification of Distributed Checkpointing Using Event-BFormal Verification of Distributed Checkpointing Using Event-B
Formal Verification of Distributed Checkpointing Using Event-B
 
Jmh
JmhJmh
Jmh
 

Más de Sperasoft

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4Sperasoft
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted WorldSperasoft
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Sperasoft
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Sperasoft
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay TagsSperasoft
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Sperasoft
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databasesSperasoft
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen FrameworkSperasoft
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective МeetingsSperasoft
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 IntroductionSperasoft
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA DevelopmentSperasoft
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to ElasticsearchSperasoft
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSSperasoft
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into KanbanSperasoft
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 ReviewSperasoft
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutesSperasoft
 
Database Indexes
Database IndexesDatabase Indexes
Database IndexesSperasoft
 

Más de Sperasoft (20)

особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4особенности работы с Locomotion в Unreal Engine 4
особенности работы с Locomotion в Unreal Engine 4
 
концепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted Worldконцепт и архитектура геймплея в Creach: The Depleted World
концепт и архитектура геймплея в Creach: The Depleted World
 
Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4Опыт разработки VR игры для UE4
Опыт разработки VR игры для UE4
 
Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек Организация работы с UE4 в команде до 20 человек
Организация работы с UE4 в команде до 20 человек
 
Gameplay Tags
Gameplay TagsGameplay Tags
Gameplay Tags
 
Data Driven Gameplay in UE4
Data Driven Gameplay in UE4Data Driven Gameplay in UE4
Data Driven Gameplay in UE4
 
The theory of relational databases
The theory of relational databasesThe theory of relational databases
The theory of relational databases
 
Automated layout testing using Galen Framework
Automated layout testing using Galen FrameworkAutomated layout testing using Galen Framework
Automated layout testing using Galen Framework
 
Sperasoft talks: Android Security Threats
Sperasoft talks: Android Security ThreatsSperasoft talks: Android Security Threats
Sperasoft talks: Android Security Threats
 
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on AndroidSperasoft Talks: RxJava Functional Reactive Programming on Android
Sperasoft Talks: RxJava Functional Reactive Programming on Android
 
Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015Sperasoft‬ talks j point 2015
Sperasoft‬ talks j point 2015
 
Effective Мeetings
Effective МeetingsEffective Мeetings
Effective Мeetings
 
Unreal Engine 4 Introduction
Unreal Engine 4 IntroductionUnreal Engine 4 Introduction
Unreal Engine 4 Introduction
 
JIRA Development
JIRA DevelopmentJIRA Development
JIRA Development
 
Introduction to Elasticsearch
Introduction to ElasticsearchIntroduction to Elasticsearch
Introduction to Elasticsearch
 
MOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JSMOBILE DEVELOPMENT with HTML, CSS and JS
MOBILE DEVELOPMENT with HTML, CSS and JS
 
Quick Intro Into Kanban
Quick Intro Into KanbanQuick Intro Into Kanban
Quick Intro Into Kanban
 
ECMAScript 6 Review
ECMAScript 6 ReviewECMAScript 6 Review
ECMAScript 6 Review
 
Console Development in 15 minutes
Console Development in 15 minutesConsole Development in 15 minutes
Console Development in 15 minutes
 
Database Indexes
Database IndexesDatabase Indexes
Database Indexes
 

Último

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Último (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Unity3D Scripting: State Machine

  • 2. Finite-State Machine Definition: This is a set of five elements: (Σ, Q, s ∈ Q, T ⊂ Q, δ : Q x Σ → Q) where Σ - the alphabet, Q - a set of states, s - the initial (start) state, T - the set of accepting states, δ - the transition function. A graph with a finite number of states (nodes) and a finite number of CMV transitions (curves).
  • 3. Two Questions How this system would help us in programming the game logic? How this approach is better than others?
  • 4. How To Use Behavior of the game object may be divided into a list of different actions: Starting State Target Searching Attack Death
  • 6. Generalization Any game component, whether a unit, or a menu based or an abstract game as a whole, which uses certain rules can be programmed by using a state machine.
  • 7. Advantages of State Machine 1. Divided, limited access to the context of state 2. Encapsulated logic for each state 3. Clarity, ability to upgrade code (source code customization) 4. Reliability
  • 8. Divided, Limited-Access Context State Each state controls only its own context and there is no need to check the set of variables for other states
  • 9. Logic Encapsulation for One State This allows you to quickly respond to errors that were found during testing, to localize them and make changes. At the same time this greatly reduced the likelihood of introducing errors into other states, because their context is not available, and their logic is elsewhere.
  • 10. Source Code Customization Behavior of the object becomes more classification-ruled and understandable. Behavior modernization takes less time and complexity associated with modifications is greatly reduced.
  • 11. Reliability Transition from one state to another occurs only in specific cases, to move from one state to another if it was not planned is not possible.
  • 12. Property of C #: Operator: “Yield" Operator: “Yield" ● "syntactic sugar" ● implement pattern: enumerator Is being used for: ● implementing collection ● dividing the methods in several steps
  • 13. Unity 3D - Specifications We will use several features Unity3D: ● Operator yield and pattern enumerator. ● Call for one of the standard object methods inherited from MonoBehaviour: - Update - FixedUpdate - Start, etc.
  • 14. Unity 3D - Specifications We need the following entities: ● States ● Manager, which manages the transition from one state to another ● Model - context of state machine, to which the state will call to perform a variety of actions.
  • 16. State. Description No need to restrict the user with inheritance. System is fairly abstract, to restrict certain properties of the state through the interface.
  • 18. States Manager: Explanation Key methods: ● Set the initial state ● Infinite state that calls the logic of the current status ● Cleanup
  • 20. Infinite Cycle. Clarification ● Possibility of correct completion ● Debug messages output ● Calling IState.Start (), IState.Cleanup (), IState.DoWork () methods ● Switch state with the help of Field NextGameState
  • 22. Awaiting Something Check one of the conditions, and if it does not suffice you pass control higher up and go back to check conditions at other times when the manager would transfer control method. This way you give a chance to any other logic to be executed in a single game flow (GAME THREAD), avoiding a whole bunch of problems related to multithreading.
  • 23. Methods For any application, we need a method to invoke the script cyclically inherited from MonoBehaviour: Update, FixedUpdate, LaterUpdate, etc. Depending on the task you should choose the right method and call it for update the state machine. Before you update the state machine it is necessary to perform the initial state install. This can be done easily in the Start or Awake methods.
  • 24. Model (context) Often there is a need preserve some information between the states was preserved some information - the context of state machine. This context could be a script that renews the state machine. It is possible to store certain flags and objects necessary for the states in this script. Also, this context may contain links to game resources and other game objects. So you pass a reference from state to state to this script. This approach will help to avoid a large number of singletons in the game.