SJK's Forum Posts

  • 15 posts
  • Well, because the event won't run when the helicopter with intended UID is destroyed, you can use event logic something like this:

    + Always

    : Bullet: set 'Is obsolete' to 1

    + For each helicopter

    + Bullet's variable = helicopter.UID

    : Set angle toward helicopter

    : Set 'Is obsolete' to 0

    + Bullet: 'Is obsolete' = 1

    : Destroy bullet

    And lol deadeye, great minds think alike hey

    OK, thanks again everyone for their help.

  • ONE more question, sorry... is it possible to find whether a UID is valid? I'm just wondering what happens if a bullet is fired, but then the helicopter is destroyed by something else while the bullet is en route.

    + For each helicopter
    + Bullet's variable = helicopter.UID
    : Set angle toward helicopter 
    [/code:sai1utxl]
    
    So here, obviously the "set angle toward helicopter" won't apply if the helicopter is gone, but is there a way to say "and if the helicopter UID is no longer valid, delete the bullet"?
  • Well, you're right, there's no easy way to access the targeted object from the turret movement. To remedy this I've added a 'Get Target UID' expression to the turret movement for the next build. You'll be able to do something like this:

    + On shoot

    : Spawn bullet

    : Set bullet private variable to Gun[Turret].TargetUID

    + For each helicopter

    + Bullet's variable = helicopter.UID

    : Set angle toward helicopter

    Then every time a bullet is shot, it will lock on to the helicopter it was shot at, and follow it.

    That's exactly what I'm after, thanks a lot! Looking forward to the next build.

  • I think you've got it right up to the end, deadeye. But if I'm reading it right he wants the bullet to keep chasing the first helicopter, even when the turret isn't targetting it, but for new bullets fired not to chase it.

    Because he's picking the first helicopter for the homing bullets and all bullets are globally homing on that target he can't have bullets chasing different targets.

    Yes, that's right.

    If the event was "on shoot at (object)", so in my example "on shoot at helicopter", then I could make the bullet follow that helicopter, or apply actions directly to the targeted helicopter, making the turret behaviour a lot more flexible.

    So my question is whether that can already be done some other way.

  • So, let me see if I've got this straight...

    The turret fires Bullet A at Helicopter 1. The bullet is a homing bullet that chases the helicopter.

    Helicopter 1 moves out of range. Helicopter 2 moves into range. The turret changes it's target to Helicopter 2.

    So now you want Bullet A to change course and chase Helicopter 2? Is that correct?

    No, sorry, I want the turret to fire at the helicopter it's currently aiming at, from the "on shoot" event. The trouble is, the specific helicopter can't be determined within the "on shoot" event, only the angle, so I can't tell the bullet which helicopter it should be chasing.

  • Thanks for your quick response, the problem is I was hoping to make the bullets chase the target, that's why I needed to find what the turret's aiming at in the shoot event, rather than just the angle.

    EDIT - actually, I suppose I could store the UID in a variable in the target acquired event, then find it again in the shoot event, is that the easiest way?

    EDIT 2 - actually, I think I have the same problem in that event too... am I best off doing it manually rather than using the turret behaviour?

  • I'm wondering how to use the turret behaviour properly... at the moment I create a turret, then if the turret does not have a target, run "Add object to target" with the object in question a sprite in my game called "helicopter".

    Then I have an action that's triggered by the "on shoot" event on my turret, which spawns a bullet and sets the angle towards "helicopter".

    I hope that all made sense.

    Anyway, the turret rotates and fires as it should when helicopters pass in range, however, it seems it always shoots at the earliest helicopter. So a helicopter can fly in range, fly out of range, another helicopter will fly into range, and the turret will rotate to face the second helicopter, but the bullet goes towards the first helicopter.

    I assume this is because the helicopter is not selected in the "on shoot" event, so it just uses the first one, but how do I fix this?

  • Another related thing, I have an event, "right click on the Routes family", and in that Routes.UID always returns the same ID. Shouldn't it refer to the Routes just clicked (the subject of the event), or don't families work that way?

  • This shouldn't be a problem. Does the shortcut player('speed') work?

    I've got the same problem. I have a family called "Routes", and I can't access private variables.

    Routes('NextPointUID')[/code:3i5t0cjs]
    
    This does not work, it says it is not a private variable in Routes (it has no problems accessing it from an action).
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm... try Array(1) instead.

    That worked, thanks again.

  • How do I use arrays?

    <img src="http://img528.imageshack.us/img528/7539/screenpy2.png">

    This doesn't seem to work, what am I doing wrong?

  • It worked! Thanks for the fast response.

  • Sorry, right click where? I must be missing something obvious, the only thing under Misc is "Destroy".

  • If later you want it to set its angle to the instance with the UID stored in its private variable

    Yes, that's what I was after, thanks.

    + For each Soldier

    + Routemarker Unique ID = Soldier('CurrentRouteMarker')

    : Soldier: set angle to Routemarker.X, Routemarker.Y

    Sorry, but I don't understand the bold part, how do I put this into the event list?

  • Here's an image of my event sheet:

    <img src="http://img502.imageshack.us/img502/811/screenshotdc9.png">

    I'm wondering if it's possible to retrieve an object by its Unique ID, so I can use it in the expression that sets the Soldier's angle (for bullet movement, it's the one I've circled in the screenshot) so it chases the correct RouteMarker.

    I know that I could just use the RouteMarker just created, but I'm planning on having a chain of RouteMarkers, each stores the UID of the next RouteMarker in the chain, which the Soldier reads and then heads towards... am I on the right track?

  • 15 posts