Line of Sight - Not working in most simple way...

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • I had this working and then did something which started causing awkward behaviour, so I deleted all of my line of sight code and started over. I am at a very simple form of line of sight and its not working and its blowing my mind.

    Obstacles: Solids

    Range: 400

    Cone of View: 360

    Use Collision Cells: Yes

    Event:

    Enemy has LineOfSight to Soldier -> Set SeesEnemy 1

    Thats it....and its not working at all.

    The enemy spawns on the right side of the window, uses pathfind to find a path to a random Solider. The objective is that when it triggers lineofsight to soldier I will change the speed to make the enemy stop. (it was working before without issue). On Create the enemy finds the path, moves along the path, but when its within line of site range it does nothing, just continues to the Soldier and stops when it arrives, never triggers lineofsight at all. I am absolutely baffled.

    Quick Edit. I have the Soliders using a line of sight behaviour as well, and they trigger line of sight fine, and throw squares at the enemy when they are within range. So line of sight does work with Soliders, but not Enemy even in the most simplest form.

  • I figured it out, but it doesn't seem right.

    I disabled Solid Behavious on the Soldier and it started getting LOS to the Solider Correctly. However the Enemy has solid behaviour and Soldiers are able to line of sight them just fine. Something is wrong or I am missing something extremely obvious.

  • Figured it out again even though I still think it shouldn't behave this way. Solider LOS obstacles was set to Custom, while Enemy was set to Solid.

    So Enemy cannot see Soldier when LOS Obstacle on Enemy is set to Solid, and Soldier has Solid Behaviour Enabled.

    Is it because Enemy is seeing Soldier as an Obstacle instead of a Target, even though I have it specifically looking for that Soldier Object?

  • This is true. If you set an object as obstacle, it can not see to a point into that object.

    If you set an object as obstacle, you can not find a path to a point into its collission polygones too.

    Remains the question, why solids ? Is it needed ?

    I try to post you a kind of solution later today, with them all beeing solids.

  • Does this meets the needs ?

    https://www.dropbox.com/s/m5ynbp8tvpk4p ... .capx?dl=0

  • 99Instances2Go thank you very much, it is helpful beyond words. I am curious on how you would solve the overlapping problem now? So they make it to destination but all pile up and look like one object, this is not something that will be good at all in the type of game I am working on. I tried doing is overlapping at offset and such to move the object down 10 pixels or up 10 pixels if it sees an overlap but it seems to not work right. Push out from Solid (rex behaviour plugin) just doesn't look to natural it looks like they are literally pushing the object which is no good.

    There will potentially be 1-20 enemy on the map at a time, and they all need to have a line of site so when they throw rocks its not unrealistically going through the body of the enemy in front of them like its a magic rock.

  • Understood, and that is difficult. Wel for me it is. I come back to this.

  • I made a custom "flocking" system in CC to stop characters from stacking on each other. If i remember correctly I made a helper/detector sprite that was slightly bigger than the characters and it would be set to the position of each character always. If the detector was overlapping another character, then he would stop moving -> else he will move to the destination. Maybe something like this will work for you as well?

    ~Sol

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just changed the way the game is viewed instead of direct top down its more isometric looking now. This allows for z order to be used so objects/characters don't appear to be overlapping as bad.

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