How do I push a box normally

Get help using Construct 2

Post » Tue Jun 20, 2017 4:46 pm

Message: shushpo can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Hello!

So, I am trying to figure out how different game mechanics can be realised through Construct 2.
Now, I am trying to make the player to push the box in front of him.
I figured out two ways (while digging this forum): one involves Solid behavior (but it results in stuttering walk animation of a Player) and the other is without "solidifying" the object (but that results in a fact that player can't jump atop of the box).

Is there any way to make the animation play smooth, while using Solid behavior? Or is there a way to make the Player to stand atop of the box, without attaching the Solid behavior to it?

Thanks in advance!

https://media.giphy.com/media/3o7btUVczBiSPU1YLm/giphy.gif (box_1 here is without Solid behavior and box_2 is with Solid behavior)
http://i.imgur.com/VurK4Y5.jpg (here's my events sheet)
B
5
Posts: 14
Reputation: 255

Post » Tue Jun 20, 2017 5:03 pm

You should apply Physics behavior to your player and the box to make it nice and realistic.
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.

My games & gaming portal = DolyGames

If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.

Cheers,

COSMOS
B
20
S
9
G
1
Posts: 75
Reputation: 2,152

Post » Tue Jun 20, 2017 5:05 pm

You can also check the Physics Catapult example / template that comes with C2:

http://prntscr.com/fm2pzb
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.

My games & gaming portal = DolyGames

If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.

Cheers,

COSMOS
B
20
S
9
G
1
Posts: 75
Reputation: 2,152

Post » Wed Jun 21, 2017 11:59 am

DolyGamesCosmos wrote:You should apply Physics behavior to your player and the box to make it nice and realistic.


I am trying to avoid using physics, because it brings a lot of complexity in the project (and random stuff starts to happen). Thanks for the advice, though!
B
5
Posts: 14
Reputation: 255

Post » Wed Jun 21, 2017 6:43 pm

You could do this with the platformer behavior + a little bit of custom work:
1. Create an instance variable for the player called prevx.
2. Create an invisible sprite for the top of the box.
3. Set the top sprite to solid so that the player can land on it.
4. Every tick set boxtop.x + box.x
5. Box -> is overlapping player -> set box x = self.x + player.x - player.prevx
6. Every tick set player.prevx = player.x
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
46
S
11
G
20
Posts: 363
Reputation: 14,199

Post » Thu Jun 22, 2017 9:45 am

cjbruce wrote:You could do this with the platformer behavior + a little bit of custom work:
1. Create an instance variable for the player called prevx.
2. Create an invisible sprite for the top of the box.
3. Set the top sprite to solid so that the player can land on it.
4. Every tick set boxtop.x + box.x
5. Box -> is overlapping player -> set box x = self.x + player.x - player.prevx
6. Every tick set player.prevx = player.x


Sounds promising, I'll try it. Thanks a bunch!
B
5
Posts: 14
Reputation: 255

Post » Thu Jun 22, 2017 12:41 pm

Well, I've tried the method above, but it did not work for me (for some reasons). So, I tried multiple ways, including using timer and other tools.

Finally, I found an easier way to do the trick (maybe anybody will find it useful).
So, I make a box and set Platform and Solid behavior to them. I set Solid behavior initial state as "disabled".
Then, I create an event which concludes of two conditions. First: Player box is overlapping box at offset (0, 10). Second: Player box Y coordinate is less than box's Y coordinate. Then, assign an action: set Solid behavior enabled for box. Add sub-event: Else, box's Solid behavior is disabled.

This way lets you move boxes (I guess that precision can be achieved with tinkering with the Platform behavior of box) and it does not interrupt the walking animation of a player.
B
5
Posts: 14
Reputation: 255


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests