filmov
tv
Simple Score System using Playmaker in Unity3d

Показать описание
Sorry for the white on white and small text size for the score.
Here's the step by step:
- create empty game object called 'manager'
- this will handle the math and update the score and such
- rename first state to 'IDLE' and add 'FINISHED' transition
- this is the start state, does nothing
- create 'ADD POINTS' event and check to make global
- make a new state called 'ADD' and add global transition 'ADD POINTS'
- this is where math for adding score will be done
- create an 'UPDATE' state which will update the score
- on 'ADD' state add action: int add
- this tell the manager what to add to score
- create a global variable called 'pointsReward'
- change type to 'Int'
- On the 'Int Add' action in the 'ADD' state
- select 'int variable' as 'pointsReward'
- add 1 (or how many points to add to score)
- add 'FINISHED' transition to state and connect to 'UPDATE'
- create a new variable called 'scoreString'
- change type to 'String'
- this will convert the integer into a string so it can be displayed
- In 'UPDATE' state
- add action Set Gui Text (this will display the score)
- set game object as 'GUI_score'
- set text as 'scoreString'
- add action 'Convert Int to String'
- set 'int variable' as 'pointsReward'
- set 'string variable' as 'scoreString'
- in 'SCORE' state
- add action 'send event'
- event target: Game Object FSM
- GameObject: specify game object (select 'manager')
- FSM name: FSM
- Send Event: ADD POINTS
- add transition 'FINISHED' and connect back to 'IDLE'
Here's the step by step:
- create empty game object called 'manager'
- this will handle the math and update the score and such
- rename first state to 'IDLE' and add 'FINISHED' transition
- this is the start state, does nothing
- create 'ADD POINTS' event and check to make global
- make a new state called 'ADD' and add global transition 'ADD POINTS'
- this is where math for adding score will be done
- create an 'UPDATE' state which will update the score
- on 'ADD' state add action: int add
- this tell the manager what to add to score
- create a global variable called 'pointsReward'
- change type to 'Int'
- On the 'Int Add' action in the 'ADD' state
- select 'int variable' as 'pointsReward'
- add 1 (or how many points to add to score)
- add 'FINISHED' transition to state and connect to 'UPDATE'
- create a new variable called 'scoreString'
- change type to 'String'
- this will convert the integer into a string so it can be displayed
- In 'UPDATE' state
- add action Set Gui Text (this will display the score)
- set game object as 'GUI_score'
- set text as 'scoreString'
- add action 'Convert Int to String'
- set 'int variable' as 'pointsReward'
- set 'string variable' as 'scoreString'
- in 'SCORE' state
- add action 'send event'
- event target: Game Object FSM
- GameObject: specify game object (select 'manager')
- FSM name: FSM
- Send Event: ADD POINTS
- add transition 'FINISHED' and connect back to 'IDLE'
Комментарии