How do I toggle objects to spawn on 1 keyboard button press?

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi, so this thing I'm working on is intended to basically toggle whether or not something is activated or not upon a press of the spacebar. Basically I have an item that sits in the room and I want it to be so that when I press spacebar it toggles between that item and a different sprite object. I can get it to go one way fine by saying "On Space pressed Spawn Plant && Destroy Pod" but I would like it to be a togglable, so that I can press space and it will either destroy the Pod and spawn the Plant, or vice versa.

    I'm just really struggling with the syntax of this and am not really sure how to structure my events to do this. I played with instance variables but none of them really accomplished what I wanted to tell them to do.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If there is only one at a time, you can check Plant.Count to see if a Plant is created or not. Use Else for the second case.

    if Plant.Count = 1 -> Spawn Pod, Destroy Plant

    Else Spawn Plant, Destroy Pod

    A Global variable would also work, not an Instance variable.

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