How would i track if my player has walked around an object?

0 favourites
  • 9 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • Hi all, I am trying to develop a method to track if my player has completed walked around an object. To be more specific, I have a box that I want to destroy once my player has walked around it in a square motion. To do this i need to track each side of the box to see if the player and walked past it. I have included a pic below:

    Im also thinking about if the player doesn't do this in a certain amount of time then they will have to try again. For instance, if they have walked around the left and top side of the box but not the last two sides in 10 more seconds they must start over.

  • Put some invisible objects on the key areas at the corners, and when you overlap them, set a variable on the object to true. If all objects linked to the main object have variable true then destroy it. If the timer expires, set all variables back to false. That's how I would do it but there are other ways...

  • Here is an example of solution !

    This has the advantage of working for all your boxes in parallel. You just have to define the boxUID instance variables beforehand.

  • Great! That's what I was wondering next. My plan is to have multiple boxes on screen at once laid out in order like so:

    Ill give this a go tonight and report back how things went. Thank you both again!

  • So i had to edit the code a bit to get it to work but its working. The only issue i have doing it this way is that if i collide with two items on one box and two on another it will open/destroy the last box. I need to be able to destroy a box only have the 4 associated collision items are gone.

  • Hum, I'd need to see why you changed the code that way but the problem seems to be that a checkChest instance is destroyed immediately on collision. So its activated variable instance can't be checked and the last condition will never be valid. You also don't need the "Open Chest" number variable : checking each checkChest activation with corresponding chest.UID is enough.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When I change that then the first chestCheck I run into will open the chest instead of waiting for all 4. I mimic your check now before that to help stop it but now, no chest will open. Here is my capx if you wanna take a look:

    https://www.dropbox.com/s/3t3j1ohw5vby62y/chestgame.capx?dl=0

  • positronic

    you were close! PickedCount is one of my favorite things in C2 :)

    I also added an Activated animation to the chestCheck sprites just to make it easier to see what was happening...

    https://www.rieperts.com/games/forum/chestgame.capx

  • This is perfect! Thanks so much to everyone for their help on this. I really can't thank you enough.

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