The Daily Click ::. Forums ::. Klik Coding Help ::. Ledge Hanging
 

Post Reply  Post Oekaki 
 

Posted By Message

Tokinsom



Registered
  22/11/2009
Points
  25
9th December, 2009 at 03:50:42 -

What's the best way to get your player to hang off ledges? More specifically, like Samus does in Metroid:Zero Mission and Fusion.

I've got something going here but my player's hand sinks into the platform if grabbing on after falling a good distance. I've countered this by pushing the player upwards if the ledge grab detector is sunk in the platform, but then you can see the player move upwards..looks cheezy..and still doesn't align the player correctly. On top of that, this messes with the "climb up ledge" animation. Thanks for any help.

 
n/a

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
9th December, 2009 at 03:56:11 -

Never played that game, but I have a platform engine with ledge grab, but I can't figure out climb up ledge. I'll email it to you if I find it on my computer. It's been really buggy and crashy as of late. it is getting too unstable to work with.

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
9th December, 2009 at 16:29:46 -

Basically, I used the action point of the character for wherever the hand was. Then, I set an active object, about the size of his hand to the action point. When moving my character down, I also moved the hand sensor. Whenever that active object overlapped a ledge sensor while moving down, I set the status from moving down to ledge grab. Basically, I deactivated the gravity group of events and activated the ledge grab group. If the player pushed down, I would set his position to his Y position +1 and activate group gravity. If the player pushed jump, I would set his position to his Y position -1 and activate group gravity and also the jump code. If he pushed up, then start the ledge climb animation. As soon as that is over, set his position to the top of the ledge.

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

Levirules



Registered
  27/09/2008
Points
  37
18th December, 2009 at 17:58:18 -

If your code works fine but shows your player moving up one pixel every loop until he is hanging from the ledge properly, move the code that repositions him into a loop. So if your code is something like this:


If player is hanging from a ledge
If player is too low on the ledge
++Move player up one pixel


Throw it into a loop, which will take care of it all at once. Without knowing how your platform movement engine works, I have to be vague here. You'll want to start the loop for the vertical velocity of the player. So if the player is falling at a rate of 10 pixels per cycle, you want to run the loop up to ten times. The code should look something like this:


If player is hanging from a ledge
If player's vertical velocity is greater than zero
++Start loop "hanging fix" for (player's vertical velocity) times

On loop "hanging fix"
If player is hanging from a ledge
If player is too low on the ledge
++Move player up one pixel

If player is hanging from a ledge
If player is NOT too low on the ledge
If the jump button isn't being pressed (assuming jumping allows you to leave the ledge)
Only one action when event loops
++Set vertical velocity to zero


With this code, you will have to wait until after this check to change the player's vertical velocity back to zero. What this code does is ask the game if the player is currently falling AND he grabs onto a ledge. The code will check to see if he is too far down on the ledge, correct the player's height in respect to the ledge, and then set his vertical velocity back to zero so he doesn't fall off the ledge!).

 
n/a
   

Post Reply



 



Advertisement

Worth A Click