How do I line of site

0 favourites
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • i can get the sprite to change animation once im within the set pixel distance for line of sight but when i leave out of that distance it does not go back to its original animation , not sure why.?

  • Have you programmed it to return to its original animation?

    A .capx or more info on your events would be helpful for us to help you.

  • line 224 is what im referring to

  • yea you were right about it needing a animation change once animation is finished....

    some odd reason i just expect the states to go back to the original states before the line of sight is activated.

  • so i got that to work now...

    now I am having a picking issue...when the idle sprite gets within sight of the Chesnut sprite the first one switches

    animation but then i go to the other ones that i copied and pasted from within the editor do not change animation..

    i never know how my picking order should be...

  • Picking order doesn't matter; you will still end up with the same objects. Each condition is like a filter that reduces the number of objects that are picked. The exception is Pick All, which resets the picking and so increases the number of objects picked. You might sometimes need this in sub-events. Definitely re-read the manual section on Events that describes this if you're unclear on picking.

    So event 25 is saying

    "Filter out all chesnut objects except the nearest one to an Idle object, but only if it has LOS to an Idle object; then, for each one that is picked (if any; in your case there should be 0 or 1) set its animation to 'chesnutAttack'"

    So when you say "the other ones... do not change animation", are they not following your logic (above)?

  • exactly, ill destroy the first one and then go to the next one and nothing happens, no change in animation.

  • So without the full capx it's difficult to know what you mean by "ill destroy the first one" (like, which objects you're referring to). Sorry but like this it's a guessing game for me.

    If you're destroying the chesnut objects then if your event 25 is on every tick (i.e. not a subevent) then I would expect the nearest chesnut with LOS to Idle would be destroyed, then again on the next tick the nearest one with LOS is destroyed... etc. If this is not occurring, make sure there is actually an object with LOS (is the animation changing to attack?).

  • yea just an example...its on level 5....once the game starts you can hit Enter and go to the map...press z to enter and to shoot...arrow keys to move around, up arrow to jump...

    so in general i walk past the chesnut sprites and only the first one reacts, the others just stay in their idle animation..

    i copied an pasted within the editor for the duplicates...

  • I was going to upload a screenshot but the forum won't let me.

    In event 225 you have the conditions

    -------------------------------------------------------------

    Idle: pick nearest to (chesnut.x, chesnut.y)

    chesnut: Has LineOfSight to Idle

    -------------------------------------------------------------

    Surely the Idle and chesnut should be swapped in the first condition? There is only 1 Idle object so there's no point picking it.. I'll continue to look.

  • did you get the file? the capx?

  • Yes that's why I saw the above Anyway, only the first chesnut is getting line of sight AT ALL. So definitely only that one will trigger the event. I noticed that one has 'use collision cells' to No and the others are Yes. However changing that didn't fix it. Something to go on though.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So to fix it delete all the chesnuts except the first one off your layout, then re-clone the first one to where you had the others.

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