Physics: Bar of Soap in a Cardboard Box?

0 favourites
  • 14 posts
From the Asset Store
Over 2700 files with all the colour combinations from a 15 colours palette!
  • EDIT: For some reason I'm not allowed to post links in posts. Hopefully that goes away soon. I'm unfamiliar with dropbox, but it seems like I just need to input email addresses to share the .capx file.

    Hey folks, this might be a nooby question since I'm really new to Construct 2, but I'm encountering a bit of a problem in my game design. I've taken a look at the FAQ threads and a few others, but didn't quite find what I was looking for.

    So, here's a few screenshots of my game to give you a better understanding of what I'm talking about;

    [No pictures allowed? Uh, okay. Just copy and paste links, I guess.]

    i1204.photobucket.com/albums/bb412/tjasper27/Intern1_zps3d7bb0be.jpg

    i1204.photobucket.com/albums/bb412/tjasper27/intern2_zps9ccb657b.jpg

    i1204.photobucket.com/albums/bb412/tjasper27/intern3_zps23f1cfe5.jpg

    In my game, the player (the stick figure holding the dustpan taped to a broom) can use the jump feature of the platform behavior to strike the "Enter Name Box" with the dustpan. Both the dustpan and the "Enter Name Box" are physics objects. As you can see from the pictures, this allows the player to shove the Name Box along in an upwards or side-to-side motion (World Gravity is set to zero to keep the box in the air).

    Now, turn your attention to that odd yellow rectangle inside the Name Box. This is the thing that's giving me trouble. What I'd like to have happen is make it to where the yellow rectangle is "trapped" inside the Name Box, but realistically moves around the box (only with no friction)once the Name Box is manipulated by the player. Think of the yellow rectangle as a bar of soap in a large cardboard box. In the second picture I've posted, I'd want the yellow rectangle to behave by falling on to it's right side and sliding down the bottom of the Name Box until it reaches the side edge. Does that make sense?

    I've tried several uses of the physics behavior, but I'm having no luck so far accomplishing my goal. I tried adding the physics behavior to the yellow rectangle and increasing the gravity, but by doing that I cause the box to fall from above. Perhaps there's another way to keep the box in the air while granting gravity to the yellow rectangle?

    Any and all help would be much appreciated. I'll upload a capx once I figure out how.

    Thanks!

  • , once you have a dropbox account (they will need your email address for that), put the file in your Public dropbox folder. Rightclick > copy public link and paste it here. Everyone will be able to access the file.

    I think I read somewhere that links and probably images are only allowed if you have a reputation over 500

    Link 1

    Link 2

    Link 3

    <img src="http://i1204.photobucket.com/albums/bb412/tjasper27/Intern1_zps3d7bb0be.jpg" border="0">

  • As has often been said, Physics does not really interact well with behaviors such as Platform.

    Ashley actually states this HERE in a very useful tutorial on Physics (check the 2nd part for more complex info).

  • This was fun. Thanks for posting. Perhaps this will help as a starting point.

    dl.dropboxusercontent.com/u/79803565/Tilting%20boxes.capx

  • I'm trying to link to the capx, but the site won't let me. Hm...I don't know how it let me do that before.

    https://

    dl.drop

    boxuse

    rcontent

    .co

    m/u/4

    32145

    49/Int

    ern%200

    .9.ca

    px

    Ha, that did the trick!

    (Please forgive the horrible inefficiency of the framework. For future reference, what would be a better way to 'program' the events. I imagine something with local variables, but I haven't looked into that yet.)

    I appreciate the responses thus far!

    AngelEyes: I'll play around with that tilting boxes idea later tonight and get back to you. Thanks for your help.

    zenox98: Those are certainly words of wisdom. But because the platform behavior is only applied to the player and not to the dustpan (the only object that interacts with the other physics objects), does that notion still apply?

    Also, I'm totally willing to take any feedback or advice you folks have to offer. I don't intend on forcing the volunteers here to be my personal tutors, but if there's anything you see in the capx that you'd like to comment on, please do. My goal here is to learn.

  • There is a lot of interaction between the player and the devil. Perhaps using a combination of a function call, using the text as paramaters, storing the text in arrays and using your Events complete as the index array might help clean up your event sheet, especially as I presume it will get more complex as the game develops.

    You could move your physics world gravity=0 to the on start of layout instead of every tick.

    There is alot of work being done for your dustpan and tape to follow the broom around. If it remains static, you could put the tape-broom as an animation on the player, change it when appropriate and then just move the player around. The dustpan will need to remain seperate so it can be physics to interact with the box.

    Good luck

  • Here's an idea: soapinabox.capx (r146)

  • I'm afraid I'm still a bit lost. I can't quite figure out how to grant gravity-like properties to the yellow box while NOT granting them to to Name Box.

    AngelEyes, in the example you posted (tiltingboxes), how could you keep the large square box from increasing on the y axis? (That is, how could you keep it from moving down the screen, without disrupting the rest of the movements?)

    ramones, thank you for your input, but I'm afraid I'm not comprehending exactly what you've done, especially since the layout you posted cannot actually be run.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Canada GDP best username evar!

  • I think the file got corrupted when I deleted stuff. I copy/pasted everything into a new project and added comments. Try it now.

    Basically I made the box immovable and then rotate it manually when the player hits it - instead of letting the physics engine do it.

  • Canada GDP, all objects that interact must have the physics behaviour. However you can set each object to be immovable (see object physics property). The grey boxes are set to immovable, so the rectangle is just resting on the two boxes. If you hit the rectangle enough from the one side you can get it to fall off the boxes and you will see gravity take effect. The magic button, was showing how you can hide them to create the floating effect of the rectangle. It is resting, just looks like it is floating.

    There may well be better ways, but it was what I came up with to try solve your problem. Hope that is now clearer.

  • I'm out of town this weekend but I'll let you folks know how everything goes when I get back and have a chance to work on it. Thanks so much for all your input!

  • The "soap in a box" is working pretty great now, thank you!

    However, I'm encountering one final problem with it. As has been said before, Platform does not like working with Physics, and every once in awhile I can get some weird glitch to occur as a result of that (i.e. The Name Box suddenly becomes glued to the dustpan and follows it around before descending into the earth).

    It looks like I'll need to get rid of the platform behavior, which shouldn't be too big of a problem. I'll be toying around tomorrow with different ways to mimic the Platform's "jump" function.

    If anyone happens to know the "best" way to substitute the Platform's jump mechanism, let me know if you're bored. I'll probably figure out how to do it on my own, just curious if there's a really clean, efficient method.

  • Everything's worked out great! I'm right back on schedule on this game. Thanks for all the advice.

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