How do I pick a sprite based on instance variable?

0 favourites
  • 2 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have a player sprite and 10 home sprite instances. Each home sprite has variable called location, and each has their own number (Home.location=2, Home.location=3, etc.).

    Whenever I click a home sprite, I want the player sprite to move to a certain home sprite. So if I click on any home sprite, I want the player sprite to move to the home sprite with instance variable of 6.

    On tap gesture on Home = Player move to Home.X(with the instance variable of 6), Home.Y(with the instance variable of 6)

    How do I code this in the X and Y co-ordinates??

    I tried tried this

    On tap gesture on Home = Player move to Home(Home.Location=6).X, Home(Home.Location=6).Y

    but the player keeps moving to the home sprite with the instance variable of 0.

    Any help is appreciated, Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • conditions:

    on tap

    system / pick by comparison

    object = home

    expression = home.Location

    value = 6

    action:

    player move to home.x home.y

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