How to change value during game

  • Hi everyone,
    Just asking. In my game I want the speed of the character to change only when it collides with something. I currently use patrol platforms to move the character (because it doesn't need to stop) and I have values connected to their X and Y's. How can I change the value connected to all of them (Because the character consists of 4 parts) to make the character go faster. Basically the current value is 7 m/s and I want to change it to 20m/s during game then change back to 7m/s afterwards. Does this make sense?

    If I could get a response as soon as possible that would be nice because this is currently delaying the game build.


  • @Evolution

    What you are trying to do makes a lot of sense!

    Every behavior has something called an input field... If you go into the settings for the patrol behavior, you can click right next to the speed option in order to change that input field.

    Experiment with the behaviors...

    -Collided with __
    -If (input (drag from behavior)) = (smaller value)
    -Change input field (by tapping next to the setting, and put on the restart behavior option) = (larger value)

    -Stopped colliding
    -Change input field (by tapping next to the setting, and put on the restart behavior option) = (smaller value)

    You can get the smallest and largest x and y values, and define parameters. Using if-behaviors, you can figure out whether they are colliding, and then you can have the same follow-up behaviors.

    Depending on the other behaviors and how many speeds you will eventually have, you may want to turn on and off "change input field" behaviors. The idea is the same, but you're activating and deactivating the functions in this case.

    I am not good with screenshots... I can make an example though... as long as @Aidan-Oxley and @Jack8680 do not beat me to it XD...

  • Use behaviour on and off behaviours.lets think an object patrols 5 speed when object collided another object behaviour off patrol 5 and behaviour on patrol 10 and if you want to patrol 5 again you can use wait(or collided) after 7 seconds again behaviour on patrol 5 bahvşour off patrol 10

  • @Hakan Naw...

  • Set input fields are probably slightly better than behaviour on/off, but both would work depending on what exactly you are trying to do. I don't get exactly why you're using patrol to move the character, but if you want to change them alł easily, you could use a single broadcast message, and use receive message in each part. In the broadcast message select a box container that you set to the speed, then use the output from receive message as the speed of the patrol.

Log in to reply