(SOLVED)How do I make Line of Sight apply individually

0 favourites
  • 11 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hello.

    So I am setting the AI for my platformer enemies. My first type is working just fine (is a pretty simple patrol) but the new type I am working on is causing me some trouble.

    So whenever the enemy has on sight the player I have set the range and the cone of view to 90, so is just sees forward. Then I have set some instance variables whenever if he has you on sight, he will shoot you.

    Everything works fine expect one thing:

    Lets call the enemy: Caster. So if Caster#1 has you on sight, doesn't matter if Caster#2 doesn't have you on sight because you ll see his proyectiles coming at you from somewhere outside the screen because the sight applies to the sprite. How can I overcome this?


  • You should add instance variable (boolean) to Caster in order to prenvets your problem

  • You should add instance variable (boolean) to Caster in order to prenvets your problem

    Could you elaborate a bit more? I am kind of a begginer.

  • You can try something like that:

    add boolean instance variable to object "Caster" (eg "SeePlayer" default false)

    Caster has LOS Player AND caster boolean instance variable "SeePlayer" is false (use invert)

    ---> Caster set boolean "SeePlayer" true

    Caster has NOT (use invert) LOS Player AND caster boolean instance variable "SeePlayer" is true

    ---> Caster set boolean "SeePlayer" true

    Pick Caster boolean "SeePlayer" is true

    ---> Caster action (whatever you want Caster must do)

    You could improve this with adding timer for reload time or using functions

  • I already had something like that set up if true stop walking and start shooting and if false keep the patrol.

    My problem is like I said, if I have both casters one of each side, if one spots me, the other one shoots. I kinda need to make them unique or something like that to the sight.

  • could you share the capx?

  • Gotta go to work right now. I will try to do when I come home. You can check the platform AI on the store, is the one I have as example to learn.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok so here's the capx. Hopefully you can help me.


  • on event 20, you set boolean "sight" to all the familie instead of set boolean only for the Caster who has LOS your player

  • That was it, thanks dude. I didn't think that would mess it up. Still not sure when to use families. I did that so I could use it for future enemies but didnt think it will bug it out.

  • You can use families but if you have a condition with one member of your families, you just don't change state of your entire families but just the picked instance

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