How to get/use instance variables in events?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I have a world map with a bunch of "Locations". These are all the same object, and I have added their names as instance variables as well as the name of which location the player will get to if they press left/right/up/down on the keyboard.

    Example:

    My hero has a "CurrentLocation" instance variable (could also have been a global variable)

    I want to use the pathfinding behaviour to make my hero move to the next town, so I need to insert the X and Y of the next location for the pathfinding behaviour to run. How do I get this?

    I basically want to: "set NextLocationLeftX = Hero.CurrentLocation.ConnectedLocationLeft.ImagePointX" But I can't figure out how to refer to or get specific instance variables, or how to connect them in a smart way to get this type of nested information.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • object.instanceVariable

  • There is a bit of an issue I guess as you are picking the same location object from and to. Setting global variables 'on arrived' may help for next location then you can say 'on keyboard up' pick location where name = gv nextlocationup and pathfind there.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)