Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: gearedgeek on July 06, 2016, 11:11:58 PM
-
Please note that I'm very new to playmaker. I'm trying to put together a simple defense game where the player must survive waves of enemies to win. I have looked through youtube, tutorials, and other places for examples but came up with nothing.
I'm looking to have a GameObject in the leve that the enemies are trying to destroy and that the player is protecting. I need help with figuring out how to set up that GameObject to take damage from the enemies (if enemies reaches the GameObject) and if it dies then the player loses and must restart the level.
Any help would be appreciated. Thanks
-
You need colliders on the gameobject and the enemy. then you need the trigger event actions.
watch this tutorial playlist https://www.youtube.com/watch?v=hkyUbY3Bq0A&list=PL727CB9763F77BDE0 (https://www.youtube.com/watch?v=hkyUbY3Bq0A&list=PL727CB9763F77BDE0)
-
I'm currently using the Third Person Controller to control the health of my game objects. I have AI attacking a game object that the player is defending. I would like to use playmaker to restart the game when the game object is destroyed.
How do I get the health of the game object in playmaker and when that game object reaches zero health then the game ends and the play can choose to restart the game?
EDIT:
I just figured out a quick way. I just send event from the AI (from Behavior Designer) to do damage to game object. Once the game object reaches zero health I have playmaker restart level.
-
So I have a GameObject that has a variable for its health. I was working on adding this health bar to that GameObject using the Unity Tank tutorial (https://unity3d.com/learn/tutorials/projects/tanks-tutorial/tank-health?playlist=20081). How can I get this working?
-
I have playmaker retrieve the health from the game object and set text for the health. I'm not sure how to update that text when the game object takes damage.
https://postimg.org/image/b9768xggf/ (https://postimg.org/image/b9768xggf/)
-
It looks like you know how to get the health value and convert it into a string for your GUI.
The only thing you've not done is setup a system where it will re-enter that Update State upon taking damage... It's just a case of upon receiving damage you send an event to your game object to do a health check and update the string variable with the new value.
-
Yea, I need to have playmaker update when that game object takes damage. I don't know how to do that. Any help would be appreciated.
-
Create an Event (Events tab) on the game object and Call it "Update" - Mark it as a Global Event
Right click the state you've got that sets your string and GUI and add a global transition, selecting the "Update" Event
Now, whatever is applying the damage to the object can use the "Send Event" action to tell the game object to jump to the state with the "Update" global transition.
-
Awesome, I got it working some what. It displays the number but it just adds the new number after the old one. I'm not sure how to fix that.
Also once that game object reaches zero how can I tell playmaker to ask the player to end or restart the level?
-
Sorry, I'm not sure I understand, it's displaying both numbers? or it's doing an addition rather than a subtraction?
A shot in the dark if it's a display issue... You've set a Format on your "Convert Float to String" Action. Just leave this blank.
If it's an addition rather than a subtraction, check the action on your damage dealer, make sure you're adding a negative value, or using the "Float Operator" action to Subtract.
To deal with player "Death", a simple "Float Compare" action in the "Update" state will be able to tell you if your health value has dropped below 0 and fire off a transition event to other states where you deal with ending the game
-
I changed the "Format" to none in the Convert Float to String and that fixed the text displaying multiple numbers when it updates.
Now I just need to figure how to get playmaker to end/restart level when the game object (game objective [player defends the game object]) reaches zero on that string.
EDIT:
I have figured it out. I just used String compare to restart the level when the game object is destroyed. Thanks for the help! :D
-
I'd avoid using a String Compare for this purpose to be honest.
The reason for this is, there may be a situation where the Health value doesn't equal exactly 0, but goes into negative values.
This would fail a String Compare test, but a Float Compare has an option for "Less than" 0, which would cover negative values.