Announcement

Collapse
No announcement yet.

Problem with events not retriggering

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with events not retriggering

    I am making a tower defense game currently. The game is in the same sort of style as Plants Vs. Zombies. For weapon placement, I have it set up where you click on the game grid to highlight a spot, then click the weapon you want to place. The weapon then spawns at that location. The problem is, I can only get this to happen once, meaning if I click on grid space A and the weapon spawns there, then click on space B, nothing happens. I had to add a DoOnce node to the spawn actor, as it kept firing on the same spot, I currently have two slots programmed to spawn weapons for testing purposes. Both spaces work individually, but I can't get it to refire after the first one is placed. How do I get this to refire?
    Attached Files

    #2
    DoOnce does what it says. It will never fire again unless you fire it's Reset pin first. If it's building a tower in the same spot no matter which tile you click on, that means you're not updating the spawn transform to match the tile you clicked on. You really shouldn't need the DoOnce node. You need some way of telling if the tile you click on is full or not.
    My Website

    Comment


      #3
      Thee spawn transform updates from the level blueprint, and it does update properly. I had a feeling it was the DoOnce node causing this issue. I tried plugging a variable into the Reset pin, but it got the same results. Any suggestions on what I could use instead?

      Comment


        #4
        Fire an event when you want to reset the DoOnce and allow the player to place more things

        Right click Add Custom Event. Event TileReset. Hook that up to the Reset Pin on the DoOnce.

        After spawning the actor, call TileReset.

        Alternatively you can use a DoN node, which will allow you to specify how many times a player can place things. You will still need a reset event
        Last edited by DEDRICK; 01-11-2016, 02:26 PM.

        Comment


          #5
          Doing the custom event gave me the issue I was having prior to adding the DoOnce node. It basically renables the used grid space. What I am trying to do is once that grid space is filled, I need it to not be able to spawn there again. Without the DoOnce or with the custom event on Reset, it basically is telling the program that that space is still free to place weapons. The spawn transform variable gets the location of the grid space that is clicked. It then sends that info to the game instance, which tells the weapon to spawn at that location once. But, the Do Once node stops it from spawning on any other clicked grid space. So, I guess what I am trying to find how to do is how to disable a used space while still allowing the weapons to spawn on unused spaces?

          Comment


            #6
            Just brainstorming here but you could maybe use an array of actors and a series of Finds, Gets, Removes and contains. You would build the array with Get All Actors of Class

            Find Index# of selected grid actor, Get index# - Spawn actor, remove Index#. The Contains is a boolean check, so does this actor exist in the array, if no 'Error message", if yes Spawn actor
            Last edited by DEDRICK; 01-11-2016, 06:55 PM.

            Comment


              #7
              What are your grid spaces exactly? Is each space an actor? Whenever you click on a tile, along with it's spawn transform you want to get a bool or enum that tells you the state of that tile: empty, full, or something else. Then change your behavior based on that stateā€”if it's empty, build a tower, if it's full maybe you want to bring up a menu to upgrade or destroy the tower, etc.
              My Website

              Comment


                #8
                Thanks for your assistance with this. Finally got it working this morning. I ended up setting up two functions. One ticks the slot filled after a weapon is placed. The other checks to see if the clicked space is filled. I used a sequence to execute both the DoOnce and Reset on the DoOnce node. Then used a branch to check if the grid space was filled or not (via the function). Then spawned the weapon if it was empty.

                Comment

                Working...
                X