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

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Último (20)

Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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.