How do I stop the player from falling off a platform?

Get help using Construct 2

Post » Wed Apr 30, 2014 5:21 am

Hi.

I'm curious on how to do something.

I have my player character (has the platform behavior) standing on a platform, they're able to move along it normally. Now when they get to the edge of the platform I don't want them to fall off, I want them to just stop right at the edges of it. Know what I mean?

Yes I thought about adding an invisible solid object to the edges of the platform to keep the player "inside" the platforms' boundaries, but for reasons that affect other areas of the game I CANNOT make those edge markers solid.

Any other less obtrusive ways to pull this off?

I thought about adding something like 2 image points to the edges, but not sure how I could get the character to stop moving like that.

Thanks for any help :)
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Wed Apr 30, 2014 6:53 am

You have to know the x coordinate meaning the start and end of the platform. If play.x < platform.x.start or player.x > platform.x.end then play.x doesn't move
Cyberphaze

What we build can never be destroyed
B
136
S
18
G
6
Posts: 37
Reputation: 14,744

Post » Wed Apr 30, 2014 7:46 am

Hmm, don't understand really. Not sure what you mean by platform.x.start. Construct throws an error if I try to add a value after an objects X.

Tried imagepoints instead.

player.x > than platform.imagepointx(0)
or
player.x < than platform.imagepointx(1)
Set Platform Maximum Speed to Zero

Will result in... nothing happening. I'm also not sure how I could resume the players movement if I'm stopping them once they hit the edge. Could you possibly explain further?

Thanks for helping, it appears to be fairly simple but I've always struggled with some of C2's more basic concepts lol.
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Wed Apr 30, 2014 7:52 am

That was pseudo code so it is not code that C2 will understand.

Try to store in a variable the start x coordinate of the platform and store in another variable the end x coordinate of the platform then compare with player.x
Cyberphaze

What we build can never be destroyed
B
136
S
18
G
6
Posts: 37
Reputation: 14,744


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 2 guests