The Daily Click ::. Forums ::. Klik Coding Help ::. Ramp Action
 

Post Reply  Post Oekaki 
 

Posted By Message

Tokinsom



Registered
  22/11/2009
Points
  25
1st June, 2010 at 07:14:08 -

What would be the best way to simulate "ramp physics" using the PMO? For example, a skateboard or ball is moving up a straight or curved ramp at high speeds. The faster it's moving, the higher up in the air it goes once it hits the top of the ramp.

Better yet, here's a video showing what I'm trying to do. You'll see how the object moves around ramps in the very beginning.

http://www.youtube.com/watch?v=Y0i8Wxp0wZA

Thanks.



 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
1st June, 2010 at 07:48:00 -

Maybe use a physics thing instead.

 
lol

Tokinsom



Registered
  22/11/2009
Points
  25
1st June, 2010 at 08:34:42 -

Well for one, my player isn't just a ball -.-; I'm not looking for a full blown physics engine, just something that can work around ramps. Something tells me Sonic didn't use a physics engine :X

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
1st June, 2010 at 08:42:10 -

Sonic does use a 'physics' engine, just not a modern open source one like Box2D. Every platformer you make has some sort of physics engine. If you want to replicate the movement in that video it would be quite simple with something like the Box2D extension. The only problem would be getting the polygons on the map in the right spots, though you could just use simple triangle slopes. There are too many curves in that video to get something accurate using the PMO.

Alternatively, if you want to use the PMO and simplistic ramp physics, you could have a detector on the left and right of your player near their feet, and when one of them is overlapping an obstacle and the other isn't then you know that you must be on a slope (provided that there isn't also a full wall). You could then subtract an appropriate amount of X Velocity to move the player down the slope.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
1st June, 2010 at 12:20:37 -

I think there's a site called Sonic Fan Games HQ that might have an example with slopes.

 
lol

Tokinsom



Registered
  22/11/2009
Points
  25
1st June, 2010 at 12:55:35 -

Sorry I could have been a bit more specific.. All I'm trying to do is get my player to fly up a slope/ramp once it gets past the top. It already moves around slopes/ramps fine, it just doesn't fly up into the air when going up one quickly. I've got an idea though..

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
1st June, 2010 at 13:23:22 -

If you want to do a dodgey, then just put 'slope detectors' at the top of all the slopes. Make 2 types - one for left and one for right. Then you make it so if you are overlapping one and facing the right direction and moving a certain speed, use a PMO action to make the player jump.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
1st June, 2010 at 13:26:40 -

Use the X-velocity that the object is moving at when it collides with the ramp, and then use that number to gradually increase Y-velocity and decrease X-velocity. Should work if you get the numbers right!
Best of luck to you!

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

Callebo

Possibly Insane

Registered
  10/08/2008
Points
  3988

VIP MemberPS3 OwnerGOTM AUGUST - 2009 - 3RD PLACE!GOTM OCTOBER- 2009 - 2ND PLACE
1st June, 2010 at 18:38:27 -


Originally Posted by Assault Andy
If you want to do a dodgey, then just put 'slope detectors' at the top of all the slopes. Make 2 types - one for left and one for right. Then you make it so if you are overlapping one and facing the right direction and moving a certain speed, use a PMO action to make the player jump.



This is kinda what I used for "Emo Skate Phonics", and you see how that went..

 
...Atleast thats what Batman told me!

Marko

I like you You like you

Registered
  08/05/2008
Points
  2804

Has Donated, Thank You!Game of the Week WinnerVIP Member360 OwnerDos Rules!Happy FellahCrazy EvilI am an April FoolGingerbread House
1st June, 2010 at 19:15:33 -

I loved that game!

On topic: I'll be curious to see what you do with this. Although i have never needed such a solution, i am curious to see the best way to solve it

 
Image

Subliminal Dreams. . ., daily gaming news and the home of Mooneyman Studios!
www.mooneyman-studios.webs.com

aphant



Registered
  18/05/2008
Points
  1242
3rd June, 2010 at 21:58:36 -

Basically, you want the player to maintain their speed as they move in a direction. You'll need to use vectors to do this. Wikipedia will describe them better if you don't know what they are. http://en.wikipedia.org/wiki/Euclidean_vector

Wait a moment, I'll whip up a few images real quick to explain this.

Let's say that you have a player, who moves left or right at a speed of 4 pixels per frame:
Image

They've now moved 4 pixels to the right between each frame, and are going to keep moving right:
Image

On this frame, they hit this 45° ramp halfway through their steps. I'd venture a guess to say that 99% of the movement engines we see do this: The player moves forward two pixels, then goes up one, then right one, then up one, then right one.
Image

A little more obvious in this frame, the player keeps going up one, right one, stair-stepping until they have moved right 4 times:
Image

That last image illustrates why you need to use a vector movement. The player is moving a total of 8 pixels (up+right) in order to move 4 units to the right. With a vector movement, instead of just moving the player left/right 4 pixels, you would be moving them in a direction by 4 pixels.

Let's convert that stair-stepping into a proper vector. The player's x change is 4, their y change is 4. We've got two sides of a right triangle, so all we need to do is find the length of the hypotenuse, using good ol' Pythagorean's theorem: a^2 + b^2 = c^2
• c^2 = 4^2 + 4^2
• c = 5.66

This means that by stair-stepping, the player's vector is 45° by 5.66 pixels. The player should be moving at 4 pixels, so now we have to figure out how to get a hypotenuse of 4. The answer:

Image

On a 45° ramp, the player needs to move up/right 2.82 pixels in order to move diagonally 4 pixels.



So you've adjusted for the player's speed to be correct when they go up a ramp. Now you need to actually implement this into your engine. It's really simple, depending on how you have your engine set up. All you need to do is have the player's horizontal and vertical position be changed at the same time. For example, engines that move the player based on alterable values should be setting the player's x and y values at the same time when they move, regardless if they're jumping or running.

If you implement this correctly, then the player should go flying off of a ramp automatically without requiring any extra coding.

Edited by aphant

 

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
6th June, 2010 at 04:13:11 -

I missed the part about how you detect that it's a ramp

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

aphant



Registered
  18/05/2008
Points
  1242
6th June, 2010 at 21:11:06 -

Tokinsom said he's already got ramp movement, which means there's already a method to detect ramps in place.

 
   

Post Reply



 



Advertisement

Worth A Click