0 Favourites

Destroy an object at a point

  • Hey again. I'm really loving Construct 2, and I'm having lots of fun learning how to use it, but I'm afraid I've reached a rough spot again, nothing I do seems to quite work. I'm curious as to how I would make it so when you jump. You destroy lets say... A block from underneath, like in Mario, but if you jump ON TOP of it, it doesn't get destroyed.

    Thanks in advance!

  • Couldn't you do that with actionpoints, so you have 1 on top and 1 on the bottom, and when it comes in contact with action point 2 it destroys..? i dunno really just throwing an idea your way.

  • Action point? Is that different from image point? I kind of figured out one way, but I don't like it that much. I have an image point at the bottom, and a small invisible bar that spawns on it. Once the player collides it breaks the block. BUT... for some reason it destroys all the blocks, not just that instance. Even though I have an instance variable (Bumped) that sets it off.

  • EDIT: Didn't check for new posts before I posted, I see you basically have the same thing already. Your problem with all blocks getting destroyed is that the event isn't picking them properly, usually due to how you set up events -- if you post your .capx, I can help you more on that.<img src="smileys/smiley1.gif" border="0" align="middle" />

    First, you want to make the block solid. If you don't know how to do that, click on the block in the bottom right in the object list, then add "Solid" as a behavior in the panel on the left.

    Next, you'll have to make a small invisible sprite following your player. It'll serve as your little "detector"; since two solid objects can't overlap each other, you need something that isn't solid to detect collisions. Have an "Every tick" event that sets the detector's position to your character's X and the top of their sprite (either figure out what that is manually, or say "Player.Y-(Player.Height/2)", since Y is their center).

    Now you can detect collisions between the detector and the block. So on collision between Detector and Block (you can also test to make sure your player is jumping), destroy block.

    This is what I do and works perfectly, hope my explanation was good enough!

  • Sure, here you are.

    dl.dropbox.com/u/45478479/APA.capx

    Warning, it's quite hilarious.

  • Hilarious indeed. <img src="smileys/smiley36.gif" border="0" align="middle" />

    db.tt/cVSAsruW

    Ta-da! I added two simple things to make it work. First, a variable for Collision called "ID", which you set to the BlargBlock's UID after spawning it in the start. Second, a condition for the collision event that specifies that it only picks the BlargBlock whose UID matches the ID set to the Collision bar -- that way, only that block disappears rather than all of 'em.

  • Thanks a ton, I appreciate that!

  • Alright. SO, I've got it kind of working how I want it. But... It all went down hill when I started adding more of my monsters!!

    dl.dropbox.com/u/45478479/APA2.capx

    If I could get another hand. That would be great.

    p.p.s. It's just that much more hilarious now.

  • db.tt/51KuGhLu

    Alright, this took a while to sort out... At some point I just threw out a lot of it and redid it a different way. Rather than each enemy having a collision detector, I put a single one on Alex's feet -- that gets rid of the problem of trying to keep each one on each enemy. As for the two guys on the right walking straight into the pit... well, I have no idea why that was happening, but if you take out one of the two, it works fine. Hopefully someone else can come in and explain that. <img src="smileys/smiley5.gif" border="0" align="middle" />

    Now, I gotta ask... where are these sound effects coming from? I get the feeling you're recording them yourself. <img src="smileys/smiley36.gif" border="0" align="middle" /> Music's great too, did you make that?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Hahah. Music I stole from Kirby. Sounds I made. The Noises Alex makes, were recorded by my cousin, Alex. XD And the other noises, Brick/Death of the Devil are me.

    I'm just trying to make a quick, easy game to learn the program, before I go and do anything too complicated. Thanks again for your help man!

  • No prob, sorry I couldn't help with everything. Tell Alex I said keep up the good work. <img src="smileys/smiley17.gif" border="0" align="middle" />

  • Hah. Will do. Yeah, I'm still having a problem with multiple enemies. It seems like the first one works great, the second one can only be jumped on, and the third one can't. Not really sure why it's doing that. I mean, the bricks work fine.

    (EDIT)

    OHHO! The problem was the ground tiles having physics! Removed that, and it works great! Not sure why/how that was an issue though..

  • O.o

    I would never have thought to check that. Great catch, though! <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Ha thanks! Know a quick way to make it so that the DeadAlex sprite, can pass through the terrain/enemies? Looks silly when he dies, and lands ontop of one XD

    p.s. Took forever for me to figure out the collision so that he dies when hit by their body, but not by their head! :P

  • Construct Classic had an expression for platform objects that lets you set the "collision mode", which you could set to "none" and have it pass through objects. That hasn't been implemented in C2 yet, and as far as I know there's no other way to do it...

    However! My workaround is to have it as a separate sprite that ISN'T a platform object. When Alex dies, make him invisible and then set the new sprite with his dying animation to his position, then make it fall the same way he would've.

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