Problem with Line of Sight Behavior and Custom Obstacles

0 favourites
  • 3 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Firstly pardon me if I'm posting this in the wrong place, I'm still a little new to this forum.

    So I have been using the line of site behavior in my game on enemies to tell if they can "see" the player. For obvious reasons, they shouldn't be able to see through doors, walls, ground. But i added other obstacles, giving the player opportunity to "hide" from the enemy using various objects in their environment. So I set obstacles to Custom because allowing me to dynamically set which objects are obstacles (player can use to hide) and which aren't depending on varying conditions, instead of just setting the line of sight obstacles to Solid.

    Here's my issue; A "closed door" should be an obstacle to line of sight and an "open door" shouldn't (i.e., enemy should be able to see player if the player is behind an open door). So what I did was that it set up my event sheet in such a way that at the beginning of every loop, each enemy's line of sight obstacles are cleared, then for each enemy and for each door, if the door is closed (if the door's instance variable of boolean type, aptly named open, is false, ie door closed) then add that door to the obstacles of that enemy's line of sight. But that doesn't seem to work. it seems that when I add the action Add Obstacle Door to Enemy Line of Sight, it adds all the doors, not a the specific closed door. What am I doing wrong? Does Construct's Line of Sight behavior have the ability to distinguish which instance of an object is an obstacle or do they all have to be obstacles?

  • As far as I know it only distinguishes object types. You might need an 'open door' object type that doesn't get added to Obstacles. If you had the paid version you might add 'obstacle' types to a family. Feel free to post a .capx or screenshot.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I thought as much. Creating a separate object for open doors might be my best, albeit cumbersome, option. So when I door is opened it would spawn a closed door closed door object and destroy the open door object.

    I'll post a screenshot or .capx soon enough.

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