0 Favourites

Picking a specific instance

  • 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.

  • 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 :(

  • Umm... I could create new for you. Because our source code is "top secret" :D

  • 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!

  • 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...

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • 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.

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