playMaker

Author Topic: Action not working  (Read 4469 times)

Frinckles

  • Playmaker Newbie
  • *
  • Posts: 5
Action not working
« on: March 25, 2016, 05:27:37 PM »
Hi, new to Playmaker and these lovely forums. Nice to meet everyone.

      I'm currently using Playmaker 1.7.8.4 & ThirdPersonController (TPC) 1.2.2

     ThirdPersonController handles the health of characters on it's own and luckily the TPC-Playmaker addon pack comes with a Playmaker Action that lets you get the current HP. Using this I decided to make a simple FSM to track and display HP on a simple text element but it isn't working properly.

     There are 3 Variables, and only one state:
        RawHP [Float]: Used to store the raw value from the Get Current HP Action.
        HPValue [Float]: A value that is set to the RawHP.
        HPValueString[String]: The string used to display on the text element.

     
      Get Current Health
           -Store it in RawHP
      Set Float Value
           -Sets HPValue to be RawHP
      Convert Float To String
           -Makes HPValue a string and stores it as HPValueString
      Change the Text
           -Displays HPValueString On text element.

Basically it's displaying 0, the default for the float. I don't think the "get current health" action is actually storing the variable in the RawHP variable. When I play the scene the action doesn't show RawHP in the playmaker editor and instead reverts to none. It shows up fine however when I'm not in play mode.

  I've attached the script for the Get Current Health to see if it's possibly something in there. Am I approaching this incorrectly or is there something I'm overlooking? Remember I'm a bit new to Playmaker. I hope it isn't something silly.

Edit: The gameobject and text are both being found, so that isn't a problem. I can actually change the HPValue up/down and it's being converted and displayed properly. It's just not getting the information from the get current health action and storing it for whatever reason.

 Thanks for all the help.
« Last Edit: March 25, 2016, 05:32:27 PM by Frinckles »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Action not working
« Reply #1 on: March 25, 2016, 09:42:58 PM »
Hard to tell without seeing a screencap of the state- but it might be that you need to check "every frame" on the actions- most actions that have that check box will only run once if unchecked- for something like displaying health you want to want it to continue updating- so be sure to check every frame on those-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Frinckles

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Action not working
« Reply #2 on: March 26, 2016, 03:52:02 PM »
Hard to tell without seeing a screencap of the state- but it might be that you need to check "every frame" on the actions- most actions that have that check box will only run once if unchecked- for something like displaying health you want to want it to continue updating- so be sure to check every frame on those-

  I've tried using the every frame checkbox and it doesn't appear to be working any which way. I've attached 3 screenshots of the issue including when I got into playmode.

  The gameobject (unitychan) is being found with no problems, and I've tested the text change by scaling up and down the HPValue in the inspector so that's updating properly as well.
   As I said before, it's displaying 0 -- the default float value so I'm going to guess that it's not "hooking" into the value properly or getting that information considering it's clearly showing 500 current health on the inspector (thirdscreenshot).
   You can also see from the second screenshot that the variable is reverting to 'none' at runtime.

   Here is a link for the API: http://www.opsive.com/assets/ThirdPersonController/API/class_opsive_1_1_third_person_controller_1_1_health.html
   It says that the value for health is a float, so I'm not sure why it wouldn't be storing the information. I contacted Opsive support and was told that the Playmaker action is in fact working and a float was used to store the value.

   And yeah, I'm pretty much at a loss unless somebody who owns both TPC/Playmaker or can figure out what might be causing the issue can jump in. If it helps, you can look through script for the action in my previous post and compare it with the api, perhaps something has been updated since then? I don't know enough about writing Playmaker actions yet myself.

   Thanks for your response, I hope I've been specific enough with all the information -- let me know if you need anything else.

 P.S. The FSM on the text box is disabled and unrelated.
 Double P.S. The first two screenshots are the same FSM, I just renamed it. Sorry if it added to confusion.
« Last Edit: March 26, 2016, 04:00:34 PM by Frinckles »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Action not working
« Reply #3 on: March 26, 2016, 04:37:57 PM »
Ok I see- it looks like your setup is correct- I've seen that variable blanking happen before when there was a mismatch between the Unity version and the Playmaker version-

I see you're using Playmaker 1.7.x - What version of Unity are you using? If its 5.3+ trying installing Playmaker 1.8.x
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Frinckles

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Action not working
« Reply #4 on: March 26, 2016, 05:28:20 PM »
Ok I see- it looks like your setup is correct- I've seen that variable blanking happen before when there was a mismatch between the Unity version and the Playmaker version-

I see you're using Playmaker 1.7.x - What version of Unity are you using? If its 5.3+ trying installing Playmaker 1.8.x

I just updated my Playmaker.

I'm currently using Playmaker 1.8.0 & Unity 5.3.2f1 and it's still returning 0.

Have you checked the script to see if it's hooking into the value properly? I'm not super savvy with coding but I'm beginning to think the problem has something to do with the script not grabbing the health component in the OnEnter() portion.
« Last Edit: March 26, 2016, 05:34:34 PM by Frinckles »

mdotstrange

  • Hero Member
  • *****
  • Posts: 555
    • Can't code? Who cares! Make games anyway!
Re: Action not working
« Reply #5 on: March 26, 2016, 06:56:14 PM »
I'm just a novice coder but I looked at the script and it looks good- I have a lot of experience with Opsive's other product Behavior Designer so I know the dev does great work  :)

It could be something to do with this
Code: [Select]
[CheckForComponent(typeof(Health))]
        [Tooltip("A reference to the agent. If null it will be retrieved from the current GameObject.")]

Is this FSM on the same game object that the Third person controller script is on? Or whatever you have to add to a game object to make it an "agent"? If its not it would return null and not retrieve the health-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Frinckles

  • Playmaker Newbie
  • *
  • Posts: 5
Re: Action not working
« Reply #6 on: March 26, 2016, 07:04:38 PM »
I'm just a novice coder but I looked at the script and it looks good- I have a lot of experience with Opsive's other product Behavior Designer so I know the dev does great work  :)

It could be something to do with this
Code: [Select]
[CheckForComponent(typeof(Health))]
        [Tooltip("A reference to the agent. If null it will be retrieved from the current GameObject.")]

Is this FSM on the same game object that the Third person controller script is on? Or whatever you have to add to a game object to make it an "agent"? If its not it would return null and not retrieve the health-

Yeah, the script is on Unitychan. I've tried using "Specify Game Object" and dragging UnityChan from the Hierarchy. I also just tried "Use Owner." Neither is working or making it so that the variable stays in place.


Edit:: 
 
  So I decided to just drag the Character Health script from Unitychan into the action panel and used "get property." It's displaying the 500 health and I'm assuming if I damaged the character it would update and display that damage.

  Awesome news. Although, it doesn't explain why the actual Playmaker action meant to do that isn't working. Also, I'm not sure how I would do that for every object "reading" health info in the game.
« Last Edit: March 26, 2016, 07:12:52 PM by Frinckles »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Action not working
« Reply #7 on: March 28, 2016, 02:54:24 AM »
Hi,

 The Action seems fine, you should contact the author and mention your trouble, it's the best thing to do here to make sure it's not something on your side.

Bye,

 Jean