CAPXs for Platformer Hazards/Tools

Get help using Construct 2

Post » Mon Jul 11, 2016 12:26 pm

Hey guys.

I tried making a "Pressure Plate" that triggers traps using these events:


Player is overlapping Pressure_Plate | Pressure_Plate is set to Movable

x Player is overlapping Pressure_Plate | Pressure_Plate is set to imMovable

Pressure_Plate.current_position >= Pressure_Plate.starting_position + 10 | Trap is "activated"

I also made a mediocre "Trampoline" with this event:

Player on collision with Trampoline | -20 Y Impulse force on Player

The problem is that it applies the Impulse whenever the player collides regardless of where it collides. If it collides from the bottom, the player is still flung upwards.


While this works to a certain degree, I'm not satisfied with it.
I'd like to create a pressure plate that sinks SLOWLY and SNAPS BACK INTO PLACE after a certain amount of time.

Since we're talking about pressure plates, does anyone have CAPX examples of other hazards you'd normally see in platformers?

-platforms that follow paths like in Super Mario World
-P-Switches
-Crumbling Bridges
-Collapsing Blocks when player stands on them for a certain amount of time.
-Trampolines that sink before applying Impulse force on player
-Anything else

Thank you to who ever provides examples.
Image Image Image
B
29
S
11
G
27
Posts: 729
Reputation: 16,995

Post » Mon Jul 11, 2016 3:42 pm

You can make your pressure plate sink slowly using LERP to position in on the downwards motion...

Something like; lerp(a,b,x)
[Set pressureplate.Y position] -> lerp(pressureplate.Y,desired.Y,1-0.9^dt)

You can set the desired.Y position manually, or have an instance variable set at startup of layout to be pressureplate.y+10 or whatever, then reference the variable as the B component to the lerp formula. The X component can be changed for faster or slower reaction. 1-0.9^dt is pretty slow, but you can do like 0.99 for even slower.

For your trampoline, you will need to do a Y comparison between the player and the trampoline to determine if the player is below or above the trampoline in order to apply the impulse in the correct direction;

[Player collides with trampoline]
[player.Y is greater than Trampoline.Y]
--- Impulse down

[Player collides with trampoline]
[player.Y is less than Trampoline.Y]
--- Impulse up

You can make the trampoline "sink" by having a small animation of it "bending" - then apply the impulse when the animation frame reaches the desired one. In the above example pseudo-code, you would do "play animation XYZ from beginning" instead of "impulse (angle)" then make another event that triggers the impulse once the animation is at whatever frame you like.

Hope this helps

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Fri Jul 15, 2016 4:51 am

SoldjahBoy wrote:~Sol


Thank you! I'll try those. Sorry for the late reply.
Image Image Image
B
29
S
11
G
27
Posts: 729
Reputation: 16,995


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests