Starting an action once another action is complete

I’m working on a point and click action adventure game and have been trying different ways to solve this problem with no luck. The player should be able to click the “Take” button on the interface and and then click on an item and take it or, if it is out of range, go to the item and then take it. This works except the item is immediately added to the inventory and then the player goes to where it used to be. Can anyone tell me how to make it so the player goes to the item and then picks it up once they arrive? Thanks.

You could check on Tick or a Timer to see if the AI’s location vector is nearly equal to the Location vector variable. Then if so, add to the array and all that.

Move To Location > Set Timer > Is AI Location nearly equal to Location variable? If so, clear Timer and Take. Else, keep checking (leave timer running).

Thanks for your help. I’ve been working on this but I’m not really sure how to use timers in this situation. I believe, with the way that I currently have it set up, that it is only comparing the location of the player and the item once so the timer is never cleared. The way I tried to do this before was by checking an “in range” variable set by a trigger and I’m guessing it didn’t work for the same reason. Is there a way to keep checking for the duration of the timer? I’m also not sure what to set for time or if it should be looping or not.

I take it that ‘takeitem’ function you’re setting a timer for is the one that picks up the item and puts it in the players inventory? You could put the distance check in there, so get player character location, check if it is close to the item location, like in your screenshot above but within the takeitem function. If it comes out true, put the item in the player’s inventory, and then clear the TakeItem timer (you can clear it within the takeitem function itself).

If the player isn’t near the item yet, the takeitem function would just do nothing. If you set the timer to loop like you have in the shot above (maybe make the time smaller, say every 0.5 seconds or so?), it will keep checking over and over until you get close to the item, then it will put the item in your inventory and clear itself.

Alternatively, if you have access to the player character’s movement speed, when you do the Simple Move To Location, you can get the characters location and location of the item, get the distance between them and divide it by the character’s speed. This should give you the approximate time it will take to get to the item’s location, then you can plug that value into the 'time" pin of the SetTimer node (so the takeitem function fires after enough time has passed to get the character to the item). Make sure the timer is not looping if you go that route though, you only need it to fire once (and therefore shouldn’t need to clear it).

Timers don’t quite work that way. Here, try setting it up like this (keep in mind this is 4.9):

Thank you both for your responses. I’m currently working in 4.8 because a bunch of stuff was broken when I upgraded the other day and I wanted to continue working on this problem instead of fixing new issues since I had limited time. I will upgrade and try to figure out what changed and then try this as soon as I get a chance but I think I am getting a better idea of how timers work already.

That worked! I think implementing a similar functionality elsewhere is also going to help me fix the other big issue I was having when I upgraded. Thank you!

Awesome news! I’m glad to help :slight_smile: