Having problems with random events firing? Possible solution

This forum is currently in read-only mode.
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • 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.

    However.

    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

    etc

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)