Fails to fire cannon

0 favourites
  • 9 posts
From the Asset Store
Top down zombie survival mechanics pack in the style of Cannon Fodder.
  • cyborgsattack.com/files/notfiring.PNG

    So the basic concept is this:

    Cannons (actually the whole family but i have tried family to family, now trying cannon to family)

    This code, detect line of sight, as it is true, then the cannon uses the turret to rotate nicely to the cyborg, and looking at debug shows "has target" is true for the turret portion, but it never fires.

    Now, if i remove it from the LOS and put it alone, that then turns towards the cyborg first in group or nearest, and fires. The only difference is i want LOS because of obstacles in the way, without LOS it fires regardless of solid obstacles because Turret behavior has no LOS, only distance and angle.

    So what works in this setup, the turret or turret family depending on how i setup that thing, works for LOS, then when LOS is true then cannon in turret family rotates towards the target like it should, but never ever fires while in that LOS grouping.

    Only when i remove it from the LOS grouping does the cannon in with the turret behavior, work.

    What i have proven so far is that family units can target other family units and fire weapons, this removes a lot of problems in general for me, as in a lot of events down to just family vs family. But what i fail at is simply putting LOS as part of the behavior tree. I need turret so that i can control the rotate speed and then fire based on if it can fire.

    Any suggestions? i doubt this is a bug but probably something simple and stupid i am not doing.

  • See how the "On Turret2 shoot" event has a little green arrow on it? This means this is a triggered event. Try not to put triggered events nested under some other events, they should always be at the top-level!

    So try changing your code to this:

    Cannon1 On Turret shoot
     Cannon1 has LOS to Cyborgs -> Cannon1 spawn CannonFire
    

    The cannon will follow cyborgs, but only fire at them when they are in sight.

    .

    If you want your cannons to ignore targets that are behind obstacles, this becomes more complicated. In this case you should remove "Add target" action and use "Acquire target" instead. "Acquire target" assigns a specific instance of the enemy object to the turret.

    So your code could be something like this:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's just it, my events the enemies are in line of sight, and they don't fire.

    They should, the moment they have LOS

    I'll try again with switching it around, I tried both ways

    And I will try what you suggested.

    Scenario A, cannon follows target, has target true, does not fire.

    cyborgsattack.com/files/ScenarioA.jpg

  • Is the sound played? Maybe there is something wrong with the bullet (spawned on the wrong layer, for example). I suggest you add debug output (Browser->Log) to different events to see if they are getting triggered.

  • Sound does not play either, the problem is when I add LOS either as parent or child. I will add that additional debug like you suggest. Without LOS the turret event works just fine but obviously I have no LOS limit.

  • Maybe your LOS settings are wrong - distance too short or something similar. It would be easier if you could share the project file.

  • I will have to create a new simple project to share with the same results, I can't share the current project.

    LOS distance is 300 with angle of 240. LOS distance matches Turret distance. Turret tracks target just fine. It literally is the LOS, and layers aren't the problem, Turret base is lower level than turret, Turret Fire is on same level as turret with spawn point slightly outside of turret, Turret on same level as fired object, which both on same layer as enemies and walls.

    With debug, Turret triggers but LOS sub event doesn't trigger

  • Well, you can send me your project privately if you want.

    You can find my email here.

  • Sent, hopefully you get it.

    Additionally, I changed up the LOS to custom and set that to a specific wall block and the building group, this showed me that the cone of view for LOS is from parent object origin, which means I need to somehow deal with inner cone, origin point of cone reference, with custom, it at least fires 1 time before not appearing to fire again.

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