How do I choose one object only?

Get help using Construct 2

Post » Thu Dec 31, 2015 8:15 pm

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
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Thu Dec 31, 2015 8:43 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 8:51 pm

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.
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Thu Dec 31, 2015 8:56 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Dec 31, 2015 9:07 pm

@fathybasha
To prevent pointless posting and guesswork, it is preferable to either provide screenshots of your Events or a .capx.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
77
Posts: 5,196
Reputation: 54,299

Post » Thu Dec 31, 2015 9:28 pm

You are right, i will send screenshots tomorrow.
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Fri Jan 01, 2016 9:40 am

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!
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Fri Jan 01, 2016 4:51 pm

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.
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Post » Fri Jan 01, 2016 6:17 pm

No nothing. Can you please tell me what should i do?
B
15
S
4
Posts: 153
Reputation: 1,385

Post » Fri Jan 01, 2016 9:00 pm

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.
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Next

Return to How do I....?

Who is online

Users browsing this forum: ErikSwahn and 2 guests