Keys and Doors

This forum is currently in read-only mode.
From the Asset Store
The package contains 105 sounds This sound library is perfect for voicing mechanical doors in your Sci-Fi game.
  • Guys i need your help.

    i have 3 objects. a) The playr character. b) a door. c) a door key. I wan my character to reach the next level only if he holds the key! I think that the right way to do it is to use a variable, assign a value and when the character picks up the key subtract a value form the variable. How can i achieve this? It looks easy but somehow i can't do it

  • First, you have a private variable named HasKey. Default value would be 0.

    Second, when he picks the key up, add 1 to the value.

    +Player is overlapping Door

    +Player('HasKey')=1

    Next Layout

    Basically, you want both conditions in the same event; when he is at the door, check if he has the key and allow him passage if he does.

  • So i created a new event with Player is overlapping Door but i cant exactly understand the following:

    +Player('HasKey')=1

    I'm confused

  • It's a private variable. Try the ghost shooter tutorial. It tells you about them.

  • I still don't get it! U can laugh at me now

    here is the link. Can any kind soul help me?

    http://www.mediafire.com/download.php?xomyd0tjhw2

  • Nobody is laughing mate, but it does look like you need to do some of the tutorials to get you up to speed on the way Construct works.

    As for your problem, you've added an extra instruction that sets the variable rather than adding an extra condition.

    Delete the statement that sets your variable in line 5, and then right-click the condition and select "insert new condition", as illustrated below:

    <img src="http://img21.imageshack.us/img21/103/ex1l.jpg">

    It should then look like this:

    <img src="http://img21.imageshack.us/img21/7213/ex2d.jpg">

    Now you'll need to delete the first 3 lines in your program.

    I don't know what you were trying to do there, but they don't have any conditions.

    You also appear to have some blocks hidden on layer 2, and I had to move one of them before I could get to the door when I ran it.

    Your next stop should really be the wiki and the many tutorials available.

    You'll soon get the idea.

    Sponge.

  • Cheers SpongeBrain

  • I run into another problem and no matter what i do i can't solved it.

    When i pick up the key and the player overlaps with the door the game moves to the next layout, so far so good.However, if i don't pick up the key the player passes through the door. Upon setting the door properties to solid even if i have the key i cant move to the next level!

    I've read the tutorials but i'm still confused. Construct's way of doing things is so different from Gamemaker. It's not a bad thing, just a little bit confusing!

  • I'm actually a little confused but I think I get what you mean.

    So if the player is overlapping the door and has the key, the game will instantly jump to the next layout, right?! Just put an invisible sprite that checks for overlap and the HasKey variable in front of the visible door, which can be solid now of course. That way you can get an overlap.

    Even easier: you could check for overlap at offset.

  • Why are you setting the door to sollid in the first place? Solid objects are unpassable, period. You will never overlap with them. At least, not if you're using a built-in behavior like Platform or 8 Direction.

  • Instead of using overlap with the door object i use collision with another object. Even though the door is set to solid (to prevent the player from passing through the door) it still doesn't work. I'm checking for collision and not for overlaping so i guess it doesn't matter that the door is solid!

  • Why are you setting the door to sollid in the first place? Solid objects are unpassable, period. You will never overlap with them. At least, not if you're using a built-in behavior like Platform or 8 Direction.

    I was confused about that as well. But when I checked his cap I figured that he wanted the door to be part of the level boundary.

    Actually wouldn't it be better Makis to be able to place the door anywhere in the level, so the player can overlap anytime, but only pass through the door with the key? In many platformer games doors are part of the background. So you might want to go for that. But maybe your game concept requires this. After all I don't know.

    Instead of using overlap with the door object i use collision with another object. Even though the door is set to solid (to prevent the player from passing through the door) it still doesn't work. I'm checking for collision and not for overlaping so i guess it doesn't matter that the door is solid!

    You are using collision with another object and not the door itself? But your next sentence kind of sounds like you were still using the door itself just with on collision on not overlap. Again, I'm a little confused there.

    EDIT: Oh I get it... the another object thing lol. Of course it's called like that in Construct itself. My bad. Then I guess you can't be on collision with something solid when you're using platform behavior.

    Anyway, I made small changes to the cap you posted. It works with offset. Remember if the door was to be approached from a different or both directions you need to have an event with different X offset as well.

    Here is the cap

  • I'm using collision with the door itself. Ok i have to admit by english are crap:cry:

    I've managed to fix the problem using a workaround. I placed an invisible solid object in front of the door in order to prevent the player from passing through. The example you post it mate does the job fine and without using 'fake' objects, even though i can't fully understand this offset command.

    Sometimes i feel i have the brain of an 8 year old!

  • I think your english is fine. I just get confused easily.

    Well if you're using overlap at offset it's like you're checking if the object would overlap if it was at a different position. So I'm using (-1,0) offset in the example. Which means that it checks for overlap using the X position of the object minus 1. The Y position remains unchanged since it's 0. Hope that clarifies it a little.

    But if you're happy with the use of another sprite, go for it. Anything that works is okay.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the clarification PixelRebirth. The fewer objects i use in a game the more manageble it is. The game i've created with GameMaker used a lot of unnecessary objects and after a while it become quite difficult to manage. In the example you've provided using the offset command

    you don't use any more objects, resulting in a 'cleaner' and easier to understand example.

    Imagine a game with twenty levels or so, each level having it's own 'false' objects, things will start getting unnecessary complicated!

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