Object Variables

This forum is currently in read-only mode.
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi! I'm new to Construct and i've worked with mod programs like Warcraft III and SCII editors. I became interested in this program because i was told that it was similar in concept to the editors i was using. However, i have one question. Is it possible to make Object variables(variables that store Objects rather numbers)? Or is there some similar function to fulfill this task?

  • Variables can only store numbers and text. Maybe use text in a way that helps you? (object name or such).

    I don't know what you would use it for as I haven't tried the editors you mentioned, but a random guess is that maybe containers will help?

    http://sourceforge.net/apps/mediawiki/c ... Containers

  • Also, you could store the object's UID together with any info you need using a hashtable.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=Hash_Table_Object

    (Look at the example)

    But most of the time you won't need to store the objects. Maybe you can explain what you're trying to achieve?

  • Ermm...well it can be used for many instances. For example, i could use object variables to store the weapons of a character into an array and access them individually should i need it. While this can be done manually without object variables, it wouldn't be as efficient without it. Basically what i want to do with it is to be able to call it as a function to perform actions without having to duplicate the trigger for different objects.

    EDIT: A good example would be what you see in Warcraft III or Starcraft 2 editors where you can store ANYTHING in a variable, from numbers to text to different types of objects. Saves alot of effort and makes your triggers more efficient. =/

  • Yes you can do that, but you have to remember that Construct isn't an editor.

    Rather its more like a programing language, without the need for scripting.

    So while the idea of allowing objects to be stored in other objects is doable, you cant just click a button and have it happen.

    You must design a system that allows a user to do that.

    A good place to start is actually a combination of Vati-nyan and tulamide's posts, a hash table in a container with an object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok this is what i'm having trouble with:

    I'm trying to make a sports type game. All "players" use the same sprite. Players can pick up the ball and when that player collides with another player the ball will be dropped.

    Now, how do i help the game determine which player is holding the ball, and how do make triggers detect which player is affected by the collision, since they're all using the same sprite?

    (For example, the following trigger event "On collision between Player (Sprite) and Player (Sprite)", how do i let Construct know which Player (Sprite) i'm referring to in any conditions or actions attached to this event? For instance, i want to attach another condition which checks whether the colliding Player has the ball(which i use a private variable to determine if the player has the ball)

    EDIT: The only way i can see this being done is to have separate sprites for separate players, but that would mean i need to make individual triggers for ALL functions for each player sprite, which is obviously inefficient?

    EDIT2: Or am i mistaken, and that we DO need to use individual sprites for each player?

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