Little help with: variable spawns an object.

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello!!!!!

    Guys I got a situation here and I am not sure what is the solution for it, I guess I will need array, but please give me some advice so I can figure this out.

    My problem is this: I will have a character in a fight game. On beginning of each round, I would like to random some values, lets say 1 to 5 and this value will represent a weapon ID.

    This char has a variable called weapon and the random will say which weapon this char will get, and in the game I already have 5 objects using these names: 1 = dagger, 2 = sword and so.

    So on start of my layout, weapon = random (1,5) and I would like to Pin this number to my char. How is that possible? I need an array to do that?

    Something like: if weapon = 5, pin mace to char.

    Hope you can understand me and help.

    Thanks alot!!!!!!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am doing a update here to maybe clarify what I need.

    This is a very simple capx: dl.dropbox.com/u/83579758/objectpick.capx will show what I meant.

    I would like to know if is possible to once I generate 2 numbers, in this case number 1 and 2, C2 is able to spawn an object based in that value.

    I mean, if 1 comes up, then blue will spawn, if 2, red will.

    However I would like to make the program do it to me. Something like, once choose(1,2) is done, C2 will pick the object referent to this value and do the action.

    I understand somewhere I will have to tell C2 that 1 = blue and 2 = red.

    You guys understand it now?

    Thanks alot!!!! :)

  • Add the weapons to a family. When you do 'System: Create object Family..' it will spawn a random one.

  • Thank you very much for answer ramones!

    I guess that might solve what I need. Gonna try it in few minutes, thanks!

    EDIT: It worked! Thanks alot man!!!!!

  • There is another way to do it without families but it seems like you found your answer

  • If you dont mind let me know, I would like to learn. Would you please talk about it??? :)

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