How do I create only one beam per instance ?

0 favourites
  • 7 posts
From the Asset Store
High quality sound effect pack, in the following categories: Beam, Beam loop, Charging, shot
  • Hello everyone ! I'm trying to create a sort of mini-game in which a beam is reflected by lenses and it's easy to create the first beams but I don't know why, I have a problem with the "create" action. Indeed, it creates several instances of a beam sometimes but it's not supposed to be the case.

    Here is a link to get the .c3p file.

    The source of the beam is the black triangle in the middle. I can rotate it and I can rotate each lens in order to redirect the beam towards another lens.

    When a beam reaches a lens, this lens has a boolean "EmitsBeam" activated and, thanks to it, the lens is supposed to emit a new beam but I'm totally blocked ! Could someone help me ?

    Sometimes there is one beam emitted from one lens so it's OK, but sometimes no beam is emitted and other times one lens is emitting multiple beams, which is not supposed to happened.

    Thanks a lot.

  • Can't really work out how the game is supposed to work but I know that you have a trigger once for the create event inside a for each loop and that's not going to work. You need to create the beam once outside of a loop that should be easy.

  • OK lionz I see...

    To clarify, when a beam is created from a lens, its variable instance "ID" becomes equal to the Lens' UID it comes from.

    So, I would like to create an event which says this :

    If a Lens is receiving a Beam AND if no Beam with the same ID of the Lens' UID exist

    Then, create a Beam with ID equal to Lens' UID.

    But I don't know how to check if a beam with a specific variable instance exists in the scene before to create one. Could you help me on that please ?

    Thanks a lot !

  • A lens can only create one beam? It might be easier to just have an on/off variable and compare if the lens is on. To do what you mentioned you can use the conditions lens.var=UID and then set variable to lens.pickedcount, if var=0 then none exist, but maybe better to do what I first mentioned.

  • The lens has a variable instance "EmitsBeam" which is ON when a beam overlap it. It works.

    I tried to create this event :

    When a lens is ON, I try to select a beam with and ID equal to the lens UID and then I used the "PickedCount" to check if = 0 and if so, create a Beam.

    It doesn't work but maybe I missunderstood something...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sslwsh001.securedata.net/blackhornettechnologies.com/C3Samples/LaserMirror_Khodex.zip

    This kind issue is generally dealt with via a recursive function. The first object is passed to the function which passes the next object to the same function, etc. The trick is to make sure the recursion eventually stops. Sorry, I couldn't follow your events, so I isolated the solution. You can drag the mirrors around to see the interaction.

    It runs every tick, but that could be optimized to only run when something changes.

  • Thanks a lot blackhornet !

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