Simple "Is On Screen" never triggers

0 favourites
  • 5 posts
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • I have what I thought was a pretty straight forward blip of code that simply will not work, and for the life of me I can't figure out why.

    As you can see, the Web will randomly spawn a Spider at it's center every 5-10 seconds. I only want 1 Spider on screen at a time, so I've added a condition that, if the timer goes off, AND Spider is not already on-screen, THEN spawn a Spider.

    The code as pictured never spawns a Spider.

    If I simply remove the "X is on-screen", the web correctly spawns a Spider every so many seconds.

    I know for a fact there are no Spiders already on screen. Can anyone tell me WHY this won't work?

  • Are there any spiders at all? Perhaps there are no spiders that are not on screen either? Which would make the condition fail, and action not run.

  • So "on screen" specifically refers to being visible in the viewport..? That's where I was mistaken then, I was treating "not on screen" the same as not existing in the layout at all. Thanks for clearing that up.

    I figured out another way around it that doesn't even need a timer, just using the wait command for a random # of seconds instead, and that's working as expected.

  • You can use the system compare two values, spider.count=0, as an alternative.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you want to spawn a spider even if there are spiders off-screen, you can use this trick:

    Web On Timer "Spawn"
    
    .. Spider is on screen : (nothing in this event)
    
    .. Else : Web Spawn Spider
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)