Creating objects

For questions about using Classic.

Post » Thu Dec 09, 2010 6:07 pm

I created a timing system for my game, every 1000MS it subtracts 1 from the global time varible, total time length of 3 minutes.

At a specific time I want to create an object, I set it as:

Is global varible 'timer' equal to 140 - Create object.

Which works however it creates as many of those objects as it can for 1 second, and I'm unable to fix it. Does anyone know a fix?

Alternativly can someone explain how I can give each enemy a % chance to create an object upon death(There health varible = 0)

Any help would be great
B
2
G
2
Posts: 26
Reputation: 702

Post » Thu Dec 09, 2010 6:15 pm

I think I saw something like what you want the other day when looking through the starmap cap.

Put the object creation inside an event group. Have a variable for the objects you want to create. Timer equals 140 = activate group.
Upon creation:
add +1 to that variable.
Then: is variable great or equal to 1 = disable the creation group.

(Not a very graphic example, but I hope you know what I mean. Otherwise try looking into the cap I mentioned).
B
10
S
3
G
3
Posts: 110
Reputation: 2,206

Post » Thu Dec 09, 2010 6:17 pm

Totaly never thought of that, makes perfect sense, well that fixes the set spawning, anyone know how I can lets say...

5% Chance to add 1 to the varible thatll spawn the object when I destroy and object?
B
2
G
2
Posts: 26
Reputation: 702

Post » Thu Dec 09, 2010 6:23 pm

[quote:39wryl1a]Is global varible 'timer' equal to 140 - Create object.

Which works however it creates as many of those objects as it can for 1 second, and I'm unable to fix it. Does anyone know a fix?[/quote:39wryl1a]
Add a "trigger once" condition to that event.

[quote:39wryl1a]Alternativly can someone explain how I can give each enemy a % chance to create an object upon death(There health varible = 0)[/quote:39wryl1a]
Add a subevent to the event that destroys the object and add the condition system -> compare.
[code:39wryl1a]+ System: Random(2) Equal to 0[/code:39wryl1a]
That would be a 50% chance of being true.
[code:39wryl1a]+ System: Random(10) Less than to 9[/code:39wryl1a]
And this would have a 90% Chance.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Dec 09, 2010 6:35 pm

Thats great, works perfectly. Thanks very much all.
B
2
G
2
Posts: 26
Reputation: 702


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest