Picking a specific instance

Get help using Construct 2

Post » Tue Mar 27, 2012 9:54 pm

Hi! I have problem! ;D

I have object, lets say "bot". Bot has instance variable named "hp". Now I put "bot" to layout. Then I click it and copypaste by Ctrl+C Ctrl+V. Now I create another object named "player". "Player" can hurt "bot" by shooting it. I understand when bullet hits "bot" as object I can take "bot"'s "hp" away BUT how can I for example move one of all bots to some point without moving all "bot"s?

That's my problem because without that I need to code a LOT more. (I have paid version of C2. And surprise surprise I have made about 150 events of code under 2 days.)

A word for moderators: I'm sorry about subject but this is good way to intrest people to read my problem.

----------

Sorry for my bad English! Try to understand :)


Edit by Kyatric: Actualy in that forum a clear title on what's happening garnish more interest than a "shock" title.Kyatric2012-03-28 00:03:06
B
14
S
2
G
3
Posts: 8
Reputation: 3,762

Post » Tue Mar 27, 2012 10:38 pm

i would say post your capx so i can taka a look, but i won't be able to edit it because i have the free version :(
B
22
S
11
G
9
Posts: 133
Reputation: 6,572

Post » Tue Mar 27, 2012 11:03 pm

Umm... I could create new for you. Because our source code is "top secret" :D
B
14
S
2
G
3
Posts: 8
Reputation: 3,762

Post » Tue Mar 27, 2012 11:09 pm

The problem is with picking the proper instance. To do that, you should have a condition that specifies only the instance you want in the event that moves the bot; for example, if each bot was given an arbitrary number variable, you could use that like this:

Bot: RandomNum = 2;
-- Move Bot to X,Y

That'll only move the bot with its variable equal to 2, rather than all of them. So if you only want to move one, you need some way of specifying exactly which one. Or, if it doesn't matter which one, pick a random one using the "Pick random instance" System condition.

I don't know if I explained that well enough, so feel free to ask more questions!
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Mar 27, 2012 11:20 pm

You could have boolean "Active" set for your bots. You could use it like, if Bot-Active=true; move to X,Y or set angle towads position.

Then you could easily activate these bots, for example if in collision with bullet set "Active" True. Or if bot clicked set "Active" True.

You can also always use pick nearest to... or pick top/bottom...

nemo2012-03-27 23:26:10
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Wed Mar 28, 2012 12:04 am

As said above, it appears to be a picking problem.
Have a look at the "How do I FAQ" in the section "Picking/selecting instances" and browse through the items, all the explanations/tricks/codes you need are there.Kyatric2012-03-28 00:04:57
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793


Return to How do I....?

Who is online

Users browsing this forum: Artpunk, gregorysforster, onzephyr and 3 guests