License from €75 Log in
DE EN FR ES IT CZ

Check characters position [SOLVED]

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 3 years ago
    Hello!

    I'm trying to dynamically track the position of one character relative to another so that something happens. In definition script:

    please tell me why it works like this?

    function checkCharPos()

      if game.CurrentCharacter.Position.x == Characters["name"].Position.x then

      print("yes") 

      else

      print("no") 

      end

    end

    registerEventHandler("mainLoop", "checkCharPos") this does not work:

    And this does not work:

    local pos1 = game.CurrentCharacter.Position.x
    local pos2 = Characters["name"].Position.x

    function checkCharPos()

      if pos1 == pos2 then

      print("yes")

      else

      print("no")

      end

    end

    registerEventHandler("mainLoop", "checkCharPos")

    ???

    Thank you
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 3 years ago
    The second one is probably not working because you are storing the value in a variable outside of the function & thus it's not actually updating it each time, I think.


  4. · 3 years ago
    The second one is probably not working because you are storing the value in a variable outside of the function & thus it's not actually updating it each time, I think.



    O, yes, thank you!

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?