Having problems with random events firing? Possible solution

For questions about using Classic.

Post » Thu Aug 19, 2010 12:24 pm

Keywords: wrong event, event triggers, spawning incorrect

By somewhat pot luck, I found an odd bug with the for each loop. I don't know if it's a bug with construct or not - and I don't know how I'd go about testing it.


If you have a for each object, and no other condition in the even, and a subevent below that (with or without conditions) it seems to cause weirdness. I mean wierdness because everything will seem to be fine. For example, In my stationary gun game, every 5-10 shots an enemy would spawn right as the bullet spawns, often with a strange angle (there are absolutely no events that ever set that object's angle). However, the bullet does have an angle set. By luck, rarely one of the enemies would survive being killed by the bullet - perhaps because the collision event was missed or something.

Ok so like this:
On left button
System - create a bullet at gun's "bullet_point"
Set bullet.angle to gun.angle

Why is it spawning an enemy? Dunno. But it seems that the spawn an enemy event gets crossed up with the bullet spawning process, even though those events are well separated in the event list and share nothing in common other than a collision event.

After discovering this oddness, I went through backups until I found one where the problem wasn't occurring. I then one by one transferred any new events to the layout (tediously) and debugged each time. That's when I found that the for each was causing the troubles. I replaced that with a more sensible condition and I haven't seen the problem since (Well, actually once but I immediately realised what I'd done).
Posts: 42
Reputation: 884

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests