Search Unity

NodeCanvas - (Behaviour Trees | State Machines | Dialogue Trees)

Discussion in 'Assets and Asset Store' started by nuverian, Feb 8, 2014.

  1. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    I've also got a handful of missing components after upgrading (inspector image attached below). They are all on NodeCanvas connections. The DialogueConnection you see below is just an extension I've made of ConditionalConnection with some extra UI stuff for the canvas.

    The missing component can't be removed in the Inspector, unfortunately. Any idea how?
     

    Attached Files:

  2. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    I have been looking at this resource (NodeCanvas) for several hours now to determine if I can use it.

    One question (which may have already been answered, I didn't read this entire thread).

    It appears that the entire thing is based on NavMeshAgent, BUT my current, in process, game is in space, 3d space. How difficult would it be for me to change it to be based on a base class that I use for agents and then write my own actions, etc...? Or, am I missing something?
     
  3. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello,
    What is that is missing/should be there? Are these some custom conditions? Are all the script you had before, in the project now?
    By the way, you can remove missing components through the 'gear' icon.
    Thanks

    Hello,
    NodeCanvas is not based on NavMeshAgent in some way. It simply includes a couple of actions that move the agent with NavMeshAgent. NavMeshAgent is not required in any means.
    You can easily write your own actions or conditions to move your agent(spaceship?) however you like.
    You can event use Script Conrtrol tasks to call functions or get/set properties directly on one of scripts attached on any of your game objects.
     
  4. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    They very well could have been custom conditions, so probably my fault. It's possible I blew some away in the delete+upgrade process.

    Everything seems to work just the same, though, after removing them, so.. um, nothing to see here!
     
  5. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    I don't know if that's your case, but it's a bad idea to keep custom NC tasks, -or for example ones that I frequently post in this forum or official forum-, into the original NC folder. Well, same goes for any unity asset. I hope you didn't lose anything important when deleting that folder :/
    In my part, I always have a test project with NC version of at least 2 versions older than the latest and make sure that the upgrade is totaly successful before submiting. Well, considering that people don't change the source code that is :)
     
  6. Clyde_Coulter

    Clyde_Coulter

    Joined:
    Jul 14, 2014
    Posts:
    58
    Thanks for the reply, @nuverian.
    Okay, I'm going to give it a try. Going back to the asset store to buy.
     
  7. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey thanks :) Enjoy
     
  8. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi there!

    I have a new help request for you nuverian! :D

    My BB variables count is growing too fast, and i need to condense some data. For example: I have all the character attributes in a custom class into the script i used to work with before nodecanvas. something like this:

    Code (JavaScript):
    1. class playerAttributes {
    2.     public var soldierName : String;
    3.     public var soldierPortrait : Texture2D;
    4.     public var health : int;
    5.     public var accuracy : float;
    6.     public var strength : float;
    7.     public var perception : float;
    8.     public var maxAPs : int;
    9. }
    Now i'm moving all to use it trough NC but i can't get the custom BBVariables declaration right. As always my fault :p

    Please, could you explain more in detail how to use the Hero example in JS if possible, or if not, in C will be fine, but i need to know how and where you declare the variables or the types. is it declared in a custom script only for this purpose? One for each custom var you want to use? and so on...

    Thanks a lot! ;)
    Cheers!
     
  9. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    This is not working in current NC. There is no method info.DoneSpeaking();. So how do you end the dialogue.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using NodeCanvas;
    4. using NodeCanvas.DialogueTrees;
    5.  
    6. public class TypeInExample : MonoBehaviour {
    7.    
    8.     string displayText;
    9.    
    10.     void OnEnable(){
    11.         EventHandler.Subscribe(this, DLGEvents.OnActorSpeaking);
    12.     }
    13.    
    14.     void OnDisable(){
    15.         EventHandler.Unsubscribe(this);
    16.     }
    17.    
    18.     public IEnumerator OnActorSpeaking(DialogueSpeechInfo info){
    19.        
    20.         displayText = info.actor.actorName + ": ";
    21.        
    22.         for (int i = 0; i < info.statement.text.Length; i++){
    23.             displayText += info.statement.text[i];
    24.             yield return new WaitForSeconds(0.05f);
    25.         }
    26.        
    27.         yield return new WaitForSeconds(1.2f);
    28.         displayText = null;
    29.         info.DoneSpeaking();
    30.     }
    31.    
    32.     void OnGUI(){
    33.         GUILayout.Label(displayText);
    34.     }
    35. }
     
  10. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    You want to end the whole dialogue? StopGraph() would be the one, no?
     
  11. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Its to end the Action, not the whole Graph. :)
    DT related functions have changed so the above code is not valid for the current DT.

    I want to integrate Salsa. https://www.assetstore.unity3d.com/en/#!/content/16944 with NC.

    Although I have made an action node for using Salsa in NC. :) And it's working fine.

    I just want to adapt the above code to get some more control over things.
     
  12. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    Ah. In that case, try .Continue() instead of .DoneSpeaking() in your example above.
     
  13. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Thanks very much. It works fine. :)
     
  14. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hey,
    So let's suppose that you have declared that custom PlayerAttributes class somewhere, do the following:

    - Create a new script with name for example "PlayerData" and in this script:
    Code (JavaScript):
    1.  
    2. import NodeCanvas.Variables;
    3. public class PlayerData extends VariableData{
    4.     public var value : PlayerAttributes;
    5. }
    6.  
    The important here is that there exist a public variable named "value" and is of your custom class type.
    You will now be able to create variables of PlayerAttributes type in the blackboard :)
    Make sure to no put that new script in the NC original folder so that you don't lose it next update.

    So you can now read/write that variable in the blackboard using:
    blackboard.GetDataValue.<PlayerAttributes>("someName");
    blackboard.SetDataValue(new PlayerAttributes(), "someName");

    There is an extra step if you also want to use that new custom variable in the editor and tasks like for example the BBString, BBFloat etc are used but this is optional. If so, you must also create a custom BBVariable. You can declare that class in the same script as the above after the PlayerData:
    class BBPlayer extends BBVariable.<PlayerAttributes>{}

    So to recap, create a new script file named PlayerData.js and put this in, where PlayerAttributes is your custom class:
    Code (JavaScript):
    1.  
    2. #pragma strict
    3. import NodeCanvas.Variables;
    4.  
    5. class PlayerData extends VariableData{
    6.     public var value : PlayerAttributes;
    7. }
    8.  
    9. class BBPlayer extends BBVariable.<PlayerAttributes>{}
    10.  
    Let me know if you have any questions :)



    @msl_manni Yep, DoneSpeaking changed to Continue as Marble stated :)
     
  15. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Nice! Thanks. I'll try it in a while. I have a lot of data like that i would move to BB.

    I'll tell you more.

    Cheers!
     
  16. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    You are welcome.
    Keep in mind that an alternative work around of data communication would be to create a MonoBehaviour script with your said variables or properties, and then read/wrtie to those using Get/Set Field/Property tasks.
     
  17. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Please post c# for the following.
    Code (JavaScript):
    1. #pragma strict
    2. import NodeCanvas.Variables;
    3. class PlayerData extends VariableData{
    4.     public var value : PlayerAttributes;
    5. }
    6. class BBPlayer extends BBVariable.<PlayerAttributes>{}
    7.  
     
  18. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Code (csharp):
    1.  
    2. using NodeCanvas.Variables;
    3.  
    4. public class PlayerData : VariableData
    5. {
    6.    public PlayerAttributes value;
    7. }
    8.  
    9. public class BBPlayer : BBVariable<PlayerAttributes>
    10. {
    11.  
    12. }
    13.  
    Edit: I would recommend putting those classes in a namespace...but you see the conversion here.
     
  19. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Oh, I was referring to msl_manni. :) I wasn't sure what those classes were used for... just wanted to point out that I didn't include namespaces when I converted for him. :)
     
  20. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    It is what i was trying to do , but they are Millions ;) and it is turning into a chaos! Any way when i tried to do that, in the inspector only appear some vars not all and can't get to something like PlayerData.accuracy from get field.

    I don't know wich way could be better. One let me use the scripts i already have and other keeps everything centralised...

    I'll try both, if i can get the values right!


    Cheers
     
  21. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Sorry for the confussion!
     
  22. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Thanks very much. How can we access the members of these on the canvas.
    Condition : if Player.health < 10 then
    Action : Player.Ammo += 10
    etc....
    Any easy method?
     
  23. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    No idea, I haven't used this asset. I was just reading about it and saw your post so I thought I'd help out with the conversion ;)
     
  24. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Thanks .
     
  25. bkw

    bkw

    Joined:
    Sep 20, 2013
    Posts:
    49
    Is BBVar the type to use when I want to reference a System.Object? (Akin to BBObject and UnityEngine.Object?)
     
  26. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    I've tried this and Unity says :

    Assets/__SCRIPTS/NODECANVAS TASKS/PlayerData.js(8,24): BCE0138: 'NodeCanvas.Variables.BBVariable' is not a generic definition.

    What i'm doing wrong?
     
    Last edited: Jul 28, 2014
  27. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    I want to clarify some things for everyone regarding custom variables. Creating a custom Blackboard variable type, while it's possible, it is very specialized and realy rarely needed.

    --First Way--
    If you for example have a "Unit" class with a number of variables like name, speed, damage, portrait or whatever else, it is far more easier to just create that Unit deriving MonoBehaviour and add that Unit script on the game object that is actually that Unit.
    Code (CSharp):
    1. using UnityEngine;
    2. public class Unit : MonoBehaviour {
    3.     public string name;
    4.     public float speed;
    5.     public float health;
    6.     public float damage;
    7. }
    Then use Get/Check/Set Field tasks to directly communicate with the Unit.
    SetField.png


    Thats the most convenient, easier way.

    Furthermore because this Unit type is deriving UnityEngine.Object in the end, you dont have to create a custom variable for it, since you can just use the UnityEngine.Object variable and set it to "Unit" type with the small button on the right of the variable (next to X)
    Unit.png
    You would need this only in case you are making custom Tasks that deal with the Unit type and need the Unit as a variable, or else you would simply use Get/Check/Set Tasks as explained before.


    --Second Way--
    Let's suppose that for some reason, this don't work for you and you want to store that information outside of a MonoBehaviour and into a custom System.Object derived class.
    Deciding to go this way, means that you will also write custom Tasks to deal with that class. If you aren't into creating custom Tasks, then you don't need this and you can simply go with the previous way :). Let's suppose that you do.

    If so, the custom Unit class would look like this for example:
    Code (CSharp):
    1.  
    2. //It has to be serializable or it won't be saved
    3. [System.Serializable]
    4. public class Unit {
    5.     public string name;
    6.     public float speed;
    7.     public float health;
    8.     public float damage;
    9. }
    The custom VariableData would look like this:
    UnitData.cs
    Code (CSharp):
    1.  
    2. using NodeCanvas.Variables;
    3. //This is what lives in the blackboard.
    4. public class UnitData : VariableData{
    5.     public Unit value;
    6. }
    7.  
    With that done you can add and use a Unit variable on the blackboard:
    Note that this looks completely different than before because it doesn't derive UnityEngine.Object but rather System.Object
    CustomUnit.png

    Now, from anywhere you have that blackboard reference (like in a Task) you can do for example:
    Code (CSharp):
    1.  
    2. public class Example : ActionTask {
    3.  
    4.     protected override void OnExecute(){
    5.         var theUnit = blackboard.GetDataValue<Unit>("myUnit");
    6.         theUnit.name = "Maestros";
    7.     }
    8. }
    9.  
    You could also do exactly the same if Unit was deriving MonoBehaviour like in the first example.

    If you want to go the extra milestone, you can even create a BBVariable to use like BBFloat, BBString etc are used in tasks and nodes. You would only need this in case you want to visualy select the variable in the editor or provide a direct value instead of a blackboard variable. For that, you would have to declare a class like so possibly adding it to the same script created before, so that the whole script would look like this:
    Code (CSharp):
    1.  
    2. using NodeCanvas.Variables;
    3.  
    4. //This is what is lives in the blackboard
    5. public class UnitData : VariableData{
    6.     public Unit value;
    7. }
    8.  
    9. //This is what you use in a task to reference a blackboard variable and is optional
    10. [System.Serializable]
    11. public class BBUnit : BBVariable<Unit>{}
    12.  
    So now, you can do something like this in a custom task:
    Code (CSharp):
    1.  
    2. public class Example : ActionTask {
    3.  
    4.     public BBUnit theUnit;
    5.  
    6.     protected override void OnExecute(){
    7.         theUnit.value.name = "Maestros";
    8.     }
    9. }
    10.  

    UnitRelatedTask.png

    Verdict
    As you can see, the first way is definetely far more easier, so I recomend you to use the first way unless you really need the information/data to be stored into a non MonoBehaviour derived type in which case you would go with the second way and write custom tasks to deal with that custom class.
     
    Last edited: Jul 29, 2014
  28. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    You can use BBVar to visualy select any type of variable on the blackboard. By default it shows all variables deriving System.Object yes, but you can use an attribute over it to show specific types. That attribute is [VariableType(System.Type)]. So if you do this:
    Code (CSharp):
    1. [VariableType(typeof(Color))]
    2. public BBVar color;
    You will be able to pick any Color variable. If you take a look at the ListIsEmpty condition, I've used this to allow a selection of any 'IList' type.

    Make sure that you are using version 1.5.3 :)
     
  29. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548

    Oh God! I'm sorry! You can kill me when you want, i'm ready!
     
  30. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Haha :) dont worry
     
  31. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    It's very easy to use the first method But there is no CheckField Task. Am I missing something?
    Or there should be a CheckField Task too?

    Info please. :)
     
  32. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    My mistake. It should be there, but at least, it's here..attached :)
    Place it under ScriptControl folder in Conditions. It will be there in next version so don't worry about removing NC folder in next upgrade.
     

    Attached Files:

  33. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Thanks. The first method is best as you dont have to write any extra code to access it. :)
     
  34. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    I cant access BlackBoard in nestedDT in a FSM. If you select any node in a nestedDT then the parent BB disappears. And you cant access BB on any task.
    Please rectify the problem.

    Also when you enter a nestedDT, you cant move the NC window, unless you select a node, only then you can move the NC window.

    Edited...............

    You cant even assign an Agent or BB to the Dialogue Tree in inspector. And it behaves similar, whether nested or not.
     
    Last edited: Jul 29, 2014
  35. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi guys!

    Here is a webplayer demo of the game. You can see how works with NC(fantastic by the way! :D)

    Use "T" to end turn and see how the enemy comes to life! (With BT's)
    Use "R" to reload and "F" to toggle run.

    At the southern part of the level you will find a lot of weapons to try (Some with burst fire on) and a barrel to explode!

    Cheers!
     
  36. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    Any update on Dialogue Tree problems stated above?:rolleyes:
    If you select any node in a DT then the BB disappears. :mad:
     
    Last edited: Jul 30, 2014
  37. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hello Manni,

    Dialogue Trees work differently than BTs or FSMs in a sense that they don't have a single blackboard.

    Nested or not, the Blackboard for a Dialogue Tree is taken from the Dialogue Actor that is selected for the currently viewing node (dropdown). If the selected Dialogue Actor doesn't have a blackboard assigned, then no blackboard is shown since no blackboard wil be used in runtime. If the selected Dialogue Actor has a blackboard, that blackboard will show.
    So what you are missing here is that you should assign the blackboard that you want to use for the Dialogue Actor in that Dialogue Actor's inspector. This can be an existing blackboard or a new one. For example if the Dialogue Actor is the same as the FSMOwner game object, you can simply assign the same blackboard to both.

    The Agent and Blackboard references on the Graph inspector are not to be assigned manually, hense that they are super transparent. They are assigned automaticaly. I think I will just remove those controls in the inspector completely.

    By the way, when you first created the Nested Dialogue, a popup showed asking to add a Dialogue Actor automaticaly.

    Let me now if you have any trouble.

    Hey, cool stuff Danirey!
    Glad to see that you have progress on that.
    You forgot to mention that Space is Shoot ;)
    (I guess the build is with the older version and that's why the GUI labels show offseted?)

    Cheers!
     
  38. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Exactly! But now i'm trying to restore a backup. I messed everything by mistake.

    :confused:
     
  39. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    I was missing DialogActor - BlackBoard linking. :oops: Now its clear. Thanks. :)





    .
     
  40. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Just updated!!! Finally!

    But some errors grow up from nothing... They didn't affect to the work of NC or the game, but anyway here we go :

    ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint
    Aborting

    and

    Unable to find style 'windowShadow' in skin 'LightSkin' Repaint

    Each time i enter on a BT and go one level up says that!

    Now it can't be an updating problem... ;)

    Let me know what i 've done this time :D

    Cheers!
     
  41. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Nice. Enjoy the new version :)
    I know it but be a bit of a pain moving those folder due to using JS :/

    Regarding the error, I can't say it happens to me in this case, but I will take a look at it for why it may possibly occur.
    Thanks for reporting :)
     
  42. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Ok! You are welcome!

    Thanks a lot!
     
  43. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    The error happens here too. Cant find the reason though.
     
  44. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    This really cool looking game 'Kingdom' which uses NodeCanvas just came to my attention. The developers are making a sequel of their original flash game which you can also play here: http://www.noio.nl/2013/10/kingdom/.
    They have started a dev blog quite recently, thus make sure to stay tunes with the guys! This particular video explains some things about their AI :)
     
  45. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi nuverian,

    Could you check this task? I can't make it work. It is simple. Get the custom BBVar BBPlayer when is set to "reset" and set a value to his default!.

    it says "NullReferenceException: Object reference not set to an instance of an object" But every var needed is there!

    is this code wrong?

    Code (JavaScript):
    1.  
    2. #pragma strict
    3. import NodeCanvas;
    4. import NodeCanvas.Variables;
    5.  
    6. @Name("Update current APS JS")
    7. @Category("Jagged JS")
    8. @Task.AgentType(Transform)
    9. class NC_TASK_UPDATEAPS extends ActionTask{
    10.    
    11.     public var reset : BBBool;
    12.     public var APSrequiredForAction : BBFloat;
    13.     public var playerAtts : BBPlayer;
    14.     private var atts : BBPlayer;
    15.    
    16.     override function OnExecute(){
    17.        
    18.         if (!reset.value)
    19.             playerAtts.value.currentAPs -= APSrequiredForAction.value;
    20.         else{
    21.             atts=agent.GetComponent(Blackboard).GetDataValue.<BBPlayer>("attributes");
    22.             atts.value.currentAPs=atts.value.maxAPs;
    23.         }
    24.         EndAction(true);
    25.        
    26.     }
    27. }
    28.  
    Cheers!
     
  46. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087

    Hey,

    Yeah, the code is kind of wrong :)
    First some remarks:
    • You dont have to GetComponent for the blackboard. You aleady have that cached in an inherited property called 'blackboard'
    • When you call GetDataValue<T>, T should be the actual type that you want to get eg float, string, Player etc.
    • There is no reason to have that private atts BBPlayer, since you do your work through the blackboard directly :)
    Code (JavaScript):
    1.  
    2. #pragma strict
    3. import NodeCanvas;
    4. import NodeCanvas.Variables;
    5.  
    6. @Name("Update current APS JS")
    7. @Category("Jagged JS")
    8. @Task.AgentType(Transform)
    9. class NC_TASK_UPDATEAPS extends ActionTask{
    10.  
    11.     public var reset : BBBool;
    12.     public var APSrequiredForAction : BBFloat;
    13.     public var playerAtts : BBPlayer;
    14.  
    15.     override function OnExecute(){
    16.      
    17.         if (!reset.value){
    18.             playerAtts.value.currentAPs -= APSrequiredForAction.value;
    19.         } else {
    20.             var atts = blackboard.GetDataValue.<PlayerAttributes>("attributes");
    21.             atts.currentAPs = atts.maxAPs;
    22.         }
    23.  
    24.         EndAction(true);
    25.     }
    26. }
    27.  

    Also make sure that the variable "attributes" which you are getting is not null
     
  47. msl_manni

    msl_manni

    Joined:
    Jul 5, 2011
    Posts:
    272
    It would be nice if you post the solution. I need it badly as it is to be implemented in many places. Thanks.
     
    Last edited: Aug 1, 2014
  48. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Ok! Got it!

    I think i already tried that using PlayerAtributes type instead of BBPlqyer, but it didn't work anyway. I have mixed some concepts .:oops:

    I'll fix those things and try again.

    Thank you for the help and the scripting lessons:rolleyes:

    Cheers!
     
  49. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    I've tried again, and i get the same error.

    It is in this line : "atts.currentAPs = atts.maxAPs;"

    the player i want to get the attributes from is set and i think this is all. Here is a screen of the error:

    error.jpg

    As you can see, only actualPlayer is needed for the task when "reset" is checked. I want to use this task from outside, thats why i need to get the blackboard variable from code, because i can't acces by other way, can i? The turns FSM has to reset the APS of each player.

    Thanks!
     
  50. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Well, now it is working, but i do have to GetComponent or else it keep trowing the same error. Maybe blackboard is only if you use it from the owner FSM? i need to get the blackboard value from other object blackboard. I don't know how to explain that better, but anyway this is how the code looks like to work like it should:

    Code (JavaScript):
    1. #pragma strict
    2. import NodeCanvas;
    3. import NodeCanvas.Variables;
    4. @Name("Update current APS JS")
    5. @Category("Jagged JS")
    6. @Task.AgentType(Transform)
    7. class NC_TASK_UPDATEAPS extends ActionTask{
    8.     public var reset : BBBool;
    9.     public var APSrequiredForAction : BBFloat;
    10.     public var playerAtts : BBPlayer;
    11.     override function OnExecute(){
    12.    
    13.         if (!reset.value){
    14.             playerAtts.value.currentAPs -= APSrequiredForAction.value;
    15.         } else {
    16.             var atts = agent.GetComponent(Blackboard).GetDataValue.<playerAttributes>("attributes");
    17.             atts.currentAPs = atts.maxAPs;
    18.         }
    19.         EndAction(true);
    20.     }
    21. }
    I don't know if i understand this 100% but it is working. At least until i need something similar it is fine. :p
    (but of corse if you want to explain that for dummies like me, it is fine too :rolleyes:)

    Cheers