Change a variable value in an external script

FlowCanvas Forums Support Change a variable value in an external script

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2539
    kiwiman
    Participant

    I am programming a train simulator. I have a script attached to the train (trainControllerScript) that contains a float variable called maxSpeed set at 65. When the train collides with an object called changeSpeed I want to trigger an event that changes maxSpeed in trainControllerScript to say the value 10. How can I set up a flowCanvas graph to achieve this ? Thanks for any help

    #2545
    Gavalakis
    Keymaster

    Hello,

    To handle the Collision, you will need to use the “Collision” event node and setting the “Target” to be your train collider for example (or Self, if the flowScript is already on the same gameobject as the train collider).

    As for setting the maxSpeed float field on your code script, you can simply drag and drop the gameobject that contains your script. Doing so will open up a menu with possible things you can do with that object (get/set fields, get/set properties, execution methods and so on). Selecting Set Max Speed (will be categorized under your script’s name in that menu), will create a node.

    Once you have both nodes in the graph (event and set field node), it is a matter of connecting the nodes and assigning the node parameters

    If you have any further questions, please let me know.

    Thanks.

     

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

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