BBParameter Vector3 > Transform > Back to Vector3

NodeCanvas Forums General Discussion BBParameter Vector3 > Transform > Back to Vector3

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #12474
    arachnidjacob
    Participant

    So i LOVE the Vector3 > Transform Auto Convert, it makes creating waypoint following behaviours a breeze,

    I have a value called navTarget, which is usually a Vector3, but can be a Transform in the case of combat behaviours for example.

    Converting from a Transform to a Vector3 works just fine, however i notice when converting back, navTarget stays a Transform type, that when Null returns V3(0,0,0), resulting in some erratic behaviors.

    In the attached ActionTask Node, outPutPoint is set to the dynamic var that is navTarget, the main target blackboard variable i pass around the Tree.

    Is there a way to force the conversion back or forth one way or another, or will i need to use two blackboard values from here on out?

    Attachments:
    You must be logged in to view attached files.
    #12500
    Gavalakis
    Keymaster

    Hello!

    Sorry for the late reply.
    The automatic conversion that happens between the variables, does not ever change the actual variable type, but it rather only converts -if possible- the value from the source type, to a compatible value for the target type.

    Thus:
    A “Vector3 -> Transform” conversion, basically sets the target transform.position value to the source Vector3 value.
    A “Transform -> Vector3” conversion, sets the target Vector3 value to the source transform.position value. If the source is null though, then the target Vector3 value is set to default(Vector3), which indeed is V3(0,0,0).

    Right now, variables conversion in always two-way, but I can take a look at implementing an option to select “In, Out, or Both Ways”. Is that what you are suggesting?

    Please let me know if that helps clarifies things, or if by any chance I misunderstood your question, in which case I am sorry 🙂
    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    #12520
    arachnidjacob
    Participant

    Hi Gavalakis!

    I have a BBParameter Vector3 ( navTarget ) that I first populate with a transform,
    then later in a different nodeTree, I attempt to assign a Vector3 to that same navTarget .

    The debug lines INSIDE the script itself show the correct destination indicating they are set correctly.

    However later in the tree when I want to use the navTarget value, it uses the transform position as a value, giving incorrect behaviour.

    in the 3rd screen i’m trying to re-init the bbparameter by making a Variable variable, and assigning the value to it, but it does not seem to stick to the blackboard after it leaves the script.

    Attachments:
    You must be logged in to view attached files.
    #12549
    Gavalakis
    Keymaster

    Hello,

    Hmm.. The “navTarget” variable as far as I see, is of type Transform. As such, it is normal that when you later use the “navTarget” variable value in a task, it will return the transform.position, since the internal conversion FROM “Transform” TO “Vector3”, is by returning “Transform.position”.
    I see though that in your scripts you overwrite the .varRef by a new Variable created in the action. I am really not sure why you are doing this but this will probably create a lot of problems down the road. If you want to set the value of a variable, you can simply do outPutPoint.value = finalPoint (just like you have, but commented out).
    Generally speaking, I am not really sure what the problem we are trying to solve here is 🙁 Is there something I can do to reproduce the problem you are facing so that I can better see what that problem is and thus determine whether there is a bug, or simply some usage misunderstanding?

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    #12572
    arachnidjacob
    Participant

    Sure! Ill try to describe a test case:

    1: Bind a Vector3 BBParameter to the blackboard (navTarget), Debug its position.

    2: Assign a Transform to it. Debug its position.

    3: Then, Assign another Vector3 to the navTarget Debug its position in the same script.

    4: Then, in another node, Debug the position of the navTarget.

    In my case, when I check the position in step 4, it’s still the position of the transform assigned in step 2.

    #12573
    arachnidjacob
    Participant

    If you want to set the value of a variable, you can simply do outPutPoint.value = finalPoint (just like you have, but commented out).

    When i do this, it moves the previously assigned transform to the new position instantly. I end up having two ships teleporting each other around to where they want to go.

    #12576
    Gavalakis
    Keymaster

    Hello,

    Hmm. I created this BT based on your example to test it out, and it works fine. :/
    Is this BT correct for what you’ve described though?
    2017-10-06_19h09_13

    Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #12583
    arachnidjacob
    Participant

    So i tried your setup, i know whats wrong on my side.

    Navtarget is initialized as a Transform in some cases.
    I was using it interhangeably, and depending on what behaviour used it first, it would either be initialized as a Transform or a vector3.

    if i init it as a vector3, it seems to work just fine.

    I did find a workaround before this revelation, just posting it for posterity:

    Thanks for helping me through it.

    Attachments:
    You must be logged in to view attached files.
    #12587
    Gavalakis
    Keymaster

    Hey,
    Thanks for the follow up and the extra information. 🙂
    I am glad it’s solved for you now! It’s indeed very important to take care of the type the a variable name is initialized.
    If you encounter any other problems, just let me know.

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.