Page 1 of 2

How do I choose one object only?

PostPosted: Thu Dec 31, 2015 8:15 pm
by fathybasha
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

Re: How do I choose one object only?

PostPosted: Thu Dec 31, 2015 8:43 pm
by LittleStain
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?

Re: How do I choose one object only?

PostPosted: Thu Dec 31, 2015 8:51 pm
by fathybasha
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.

Re: How do I choose one object only?

PostPosted: Thu Dec 31, 2015 8:56 pm
by LittleStain
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..

Re: How do I choose one object only?

PostPosted: Thu Dec 31, 2015 9:07 pm
by zenox98
@fathybasha
To prevent pointless posting and guesswork, it is preferable to either provide screenshots of your Events or a .capx.

Re: How do I choose one object only?

PostPosted: Thu Dec 31, 2015 9:28 pm
by fathybasha
You are right, i will send screenshots tomorrow.

Re: How do I choose one object only?

PostPosted: Fri Jan 01, 2016 9:40 am
by fathybasha
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!

Re: How do I choose one object only?

PostPosted: Fri Jan 01, 2016 4:51 pm
by Estecka
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.

Re: How do I choose one object only?

PostPosted: Fri Jan 01, 2016 6:17 pm
by fathybasha
No nothing. Can you please tell me what should i do?

Re: How do I choose one object only?

PostPosted: Fri Jan 01, 2016 9:00 pm
by Estecka
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.