How do I choose one object only?

  • Hello,

    I made an event to open a command menu, to control the characters in my game. I made instance variable for each character that when this variable's value change to 1 the character does the command. The problem is that when the value change all the charcters do the command, i just want the one who i selected ( i press e beside a character to open the command menu, thats what i mean by the one who i selected, the who i used to open the menu). Help please.

    Thanks

  • So what is the exact event/conditions?

    In what way do you want to reference the correct instance?

    You press e beside a character..

    I'm not exactly sure what this means, but how should the computer know beside which character you are, so how would it know which character you mean?

  • I want to make the correct instance do the command i asked.

    I pinned an invisible object to the player that is bigger than the player, which acts like a radius. When the player press e and the character is overlapping with that radius, it opens the command menu.

  • Sounds great..

    If you could share your capx, it would be a lot easier..

    Without seeing the actual events, advise will be pretty abstract..

    You could for example set a variable to the uid of the character and reference that uid in the functions and/or events of the command menu..

  • fathybasha

    To prevent pointless posting and guesswork, it is preferable to either provide screenshots of your Events or a .capx.

  • You are right, i will send screenshots tomorrow.

  • gorilla is "the character", actionradius is the "radius",commandbg is the "command menu"

    as you can see this is on e pressed event: http://postimg.org/image/5429xt4l9/

    the buttons and the command menu is moved to the played HUD

    second part: http://postimg.org/image/68wc36r25/

    on clicked on one of the commands set all the instances of the gorilla (which acts like command) to 0 except the command you chose which is collectf (collect food)

    third part: http://postimg.org/image/le3ubqjcz/

    this is the collect food command itself, i don't think this photo matters but i putted it to make sure that you help me.

    Please help me, of course there are some things you wont understand so please ask me and i will an answer you,

    Thanks!

  • postimg.org/image/5429xt4l9/

    On this one I can see that pressing E brings out the menu, but is that all it does ? Is there anything inside this event that tells the overlapped gorilla that it is the "chosen one" ?

    I see nothing in your code that sorts the controlled gorilla apart from the others.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No nothing. Can you please tell me what should i do?

  • What I'd suggest you:

    • Create a global variable, a number, and name it "SelectedChara" or whatever you fancy.
    • In the event "On E pressed", add the action: "Set SelectedChara to Gorilla.UID"

    UID is the Unique ID of the object. Here "SelectedChara" will remember which instance you intend to use.

    • On every event where you tell the gorillas what to do, add the condition: "Pick gorilla with UID: SelectedChara"

    thus only the gorilla withe previously selected UID will be affected by these actions.

    Hope it helps.

  • Thanks so much Estecka, i will try this as soon as i can!

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