SJK's Recent Forum Activity

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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).
  • 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.

SJK's avatar

SJK

Member since 9 Dec, 2007

None one is following SJK yet!

Trophy Case

  • 16-Year Club

Progress

16/44
How to earn trophies