Little help with: variable spawns an object.

Get help using Construct 2

Post » Fri Apr 05, 2013 3:35 am

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!!!!!!!
B
8
Posts: 24
Reputation: 985

Post » Fri Apr 05, 2013 10:14 pm

I am doing a update here to maybe clarify what I need.

This is a very simple capx: https://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!!!! :)
B
8
Posts: 24
Reputation: 985

Post » Fri Apr 05, 2013 10:55 pm

Add the weapons to a family. When you do 'System: Create object Family..' it will spawn a random one.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Fri Apr 05, 2013 11:07 pm

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!!!!!olivete2013-04-06 02:01:54
B
8
Posts: 24
Reputation: 985

Post » Sun Apr 07, 2013 8:43 am

There is another way to do it without families but it seems like you found your answer
B
18
S
4
G
3
Posts: 436
Reputation: 4,801

Post » Sun Apr 07, 2013 10:14 am

If you dont mind let me know, I would like to learn. Would you please talk about it??? :)
B
8
Posts: 24
Reputation: 985


Return to How do I....?

Who is online

Users browsing this forum: Vallar and 19 guests