How do I pick an object using its name?

0 favourites
  • 6 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • What's the variable I use to access an objects name within a function?

    I want to do this:

    * Pick an object by its name (which is supplied by a field in an array)

    * Make it visible.

    It seems weird that I would copy the object name into an instance variable and then use that, but I can see how to do that. Surely that's not the best way?!

  • You would just pick by the variable.

  • But what is the variable? There's no variable for the name of an object.

    In Unity this might be GameObject.name, but what's the equivalent in C3?

  • Sprite is called Sprite.

    If you pick by the object you pick all the instances, or the first instance depending on the action.

    Sprite set angle to 90

    If you pick by the object instance variable you "filter" out all the instances that don't match and pick all that do.

    Sprite variable myvariable = 1 set x to sprite.x +1

    The variable isn't the only way to pick, but it is a standard one.

    Instance variables are located in the preferences side after you have selected an instance in the editor, or from the object list on the right.

    The starting tutorials should show that very well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Perhaps I didn't make myself clear.

    If I have a sprites called 'floor', 'wall', 'ceiling' etc., how would I choose one of them using their name?

  • The objects don't have a expression for their name that is a string.

    If you want to use a string to do that then you would have to use a function map.

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