Physics: Bar of Soap in a Cardboard Box?

Get help using Construct 2

Post » Thu Oct 17, 2013 6:45 pm

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.]

http://i1204.photobucket.com/albums/bb412/tjasper27/Intern1_zps3d7bb0be.jpg
http://i1204.photobucket.com/albums/bb412/tjasper27/intern2_zps9ccb657b.jpg
http://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!Canada GDP2013-10-17 19:04:12
B
12
S
2
Posts: 23
Reputation: 738

Post » Thu Oct 17, 2013 7:58 pm

@CanadaGDP, 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

AngelEyes2013-10-17 20:57:10
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Thu Oct 17, 2013 8:23 pm

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).
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,548
Reputation: 60,440

Post » Thu Oct 17, 2013 9:52 pm

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

https://dl.dropboxusercontent.com/u/79803565/Tilting%20boxes.capx
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Fri Oct 18, 2013 2:14 am

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.Canada GDP2013-10-18 02:15:29
B
12
S
2
Posts: 23
Reputation: 738

Post » Fri Oct 18, 2013 7:21 am

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
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Fri Oct 18, 2013 4:24 pm

Here's an idea: soapinabox.capx (r146)
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,680

Post » Wed Oct 23, 2013 6:26 pm

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.
B
12
S
2
Posts: 23
Reputation: 738

Post » Wed Oct 23, 2013 6:48 pm

@Canada GDP best username evar!
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Wed Oct 23, 2013 7:10 pm

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.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,680

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, LunaticCat and 8 guests