Jump to content


Photo
* * * * * 1 votes

Freestyle Parkour Physics


  • Please log in to reply
13 replies to this topic

#1 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3496 posts
  • Version:GM:Studio

Posted 04 April 2010 - 02:22 PM

  • Title: Freestyle Parkour Physics
  • Description: Pure GML platform physics example. Includes wall-jumping, multiple friction
  • GM Version: 7
  • Registered: Lite
  • File Type: .gmk
  • File Size: 15.7Kb
  • File Link: Link
Additional Info

Freestyle Parkour Physics
Example by YellowAfterlife
This nice example shows you proper gml physics (superior to about 98% of platform physics in gamemaker).
This means that character x\y are always integers and there are no collision bugs.
Controls:
On ground: Left\Right = move, Up = jump
Mid air, near wall: Left\Right (direction towards the wall) + Up = walljump \ + Down = walljump down
Tips:
Ground friction and air friction are different, as in real life (for maximum realism, you should set air friction to 0.01, but that would not make your game player's happy)
Player will never collides with obj_solid while jumping around. Don't try to use collision event.
Configure variables to suit your game physics.

Link
If you cannot access direct link, try the page link - it might be the website's database issue.
If you cannot access both direct link and website, don't worry - it's under maintance. That happens once per 2-3 months and can take up to day.


  • 1

#2 safwat1995

safwat1995

    GMC Member

  • New Member
  • 394 posts

Posted 05 April 2010 - 12:41 PM

nice, but bouncing off walls should only be possible if the player clicks the opposite direction of the wall
  • 0

#3 jagnus

jagnus

    GMC Member

  • New Member
  • 100 posts

Posted 05 April 2010 - 01:26 PM

very hard to play this, since if you just click one time to the left or the right player moves like 64 pixels<
  • 0

#4 Newly Discovered

Newly Discovered

    Harmonious Genius

  • New Member
  • 2467 posts
  • Version:GM8

Posted 05 April 2010 - 08:25 PM

I got used to it rather quickly though it's not much of a parkour rather than just a wall jumping tutorial.
Add ledge grabbing, running up walls, hold down to slide, etc..

Good luck, I'd love to see a good parkour system on GMC.
  • 1

#5 Punky

Punky

    GMC Member

  • GMC Member
  • 106 posts

Posted 12 April 2010 - 04:37 PM

nice, but bouncing off walls should only be possible if the player clicks the opposite direction of the wall

Heh, I managed to fix that easiliy.
//Walljumping
if (gl)and(kcr>0)and(!g) then

if (gr)and(kcl>0)and(!g) then
Just changed kcl and kcr around.
Originally kcl is the first code.


Now I'm working on a variable jump height based on how hard you press the UP key, because as it is, constantly jumping the same height can get annoying when your trying to do precision jumping.
Also having a tough time implementing some kind of double jump.

I managed to make a "game" with your physics example here.
Click the image to see a video.
Posted Image

Edited by Punky, 12 April 2010 - 05:47 PM.

  • 0

#6 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3496 posts
  • Version:GM:Studio

Posted 13 April 2010 - 02:05 PM

Punky,

Add to creation event of obj_player:

vj[1] = 10;//y jump#1 speed
vj[2] = 9;//y jump#2 speed
vjn = 2;//number of jumps remaining
vjm = 2;//number of jumps recieved upon landing
Replace the Yspeed manipulation code block with the following:
//Yspeed manipulation
if (!g) then
{
	yspeed += vg;
}
else
{
	vjn = vjm;
}
if (keyboard_check_pressed(vk_up) and vjn > 0 and yspeed >= -1) then
{
	vjn -= 1;
	yspeed = -vj[vjm-vjn];
}

And, nice game! (it generates nearly impossible situations sometimes, though)
Newly Discovered, I'll look if the ledge grabbing is possible to add here.
jagnus, sample parameters for more "normal" movement:
ha = 1.9;//x acceleration
hf = 1.1;//x friction
hm = 5;//x max speed
vg = 0.4;//y gravity
vj = 8;//y jump speed
vv = 0.6;
vm = 8;
vm2 = 16;
vwj = -9;//y walljump (Up) speed
vwj2 = 3;//y walljump (Down) speed
hwj = 5;//x walljump speed
vf = 1.0;//x air friction
vkl = 1.0;//key_left power
vklr = 0.02;//key_left power regeneration
vkr = 1.0;//key_right power
safwat1995, thanks.

Edited by YellowAfterlife, 13 April 2010 - 02:05 PM.

  • 0

#7 Punky

Punky

    GMC Member

  • GMC Member
  • 106 posts

Posted 13 April 2010 - 02:51 PM

And, nice game! (it generates nearly impossible situations sometimes, though)

Yea, I'm working on it still.
People aren't really liking the jumping though.

They would like the jump to be dependent on how long you hold the up key.
So you can do tiny or large jumps and not just large alone.

Either a variable height jump, or a secondary smaller double jump?

Any ideas?
  • 0

#8 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3496 posts
  • Version:GM:Studio

Posted 13 April 2010 - 02:58 PM

For secondary smaller jump, notice the quote block in my post above.
For variable height jump, add the
if (not keyboard_check(key_up) and yspeed < 0) then yspeed = min(yspeed+1,0);

  • 0

#9 youknowwho

youknowwho

    GMC Member

  • New Member
  • 54 posts

Posted 20 April 2010 - 12:18 AM

I made a library... http://www.box.net/shared/u54z7gvrmq
for those who aren't good with gml all you have to do is fill in the variables.
  • 0

#10 beeproductions

beeproductions

    Helping gmc users

  • GMC Member
  • 1132 posts
  • Version:GM:Studio

Posted 07 June 2010 - 12:12 PM

Great example:)maybe i will use it!Nice physics but to quick
  • 0

#11 3DCube

3DCube

    GMC Member

  • New Member
  • 19 posts

Posted 03 September 2010 - 09:29 AM

hey youknowwho! its me 3dcubez! i see youve seen this guy b4, hes good eh?
  • 0

#12 Dark Exiler

Dark Exiler

    GMC Member

  • GMC Member
  • 76 posts

Posted 13 February 2011 - 11:17 PM

My friend is making a platform game and he tried using this engine.
He needed platforms though that you can jump onto from below but which block you from above and he asked for my help.
I found a simple way to do this and I thought someone else using this engine might use it too.

1. Create new object called "obj_platform". Set its parent to "obj_solid". The object must have a sprite.

2. Create a new script called "place_meeting_solid" (or however else you like but just use your name later).
Paste this code into the script:
var p; // always declare temporary variables used in scripts with "var"

// finding "id" of instance at given place
p = instance_place(argument0,argument1,argument2);
if (p == noone)
  return false; // found "id" is "noone" so there is no instance = function finds no object at a place

// checking if a met instance is a platform
if (p.object_index == obj_platform)
  {if (bbox_bottom < p.bbox_top) // comparing the bottom and top sprite edges
     return true
   else
     return false; // we found platform at position but its above the object so we pretend it wasnt found
  }

// checking if met instance is a child of (has a parent being) platform
if (object_is_ancestor(p.object_index,obj_platform))
  {if (bbox_bottom < p.bbox_top) // comparing the bottom and top sprite edges
     return true
   else
     return false; // we found a child of platform at position but its above the object so we pretend it wasnt found
  }

// we found an object ("p" wasnt "noone") of given type, it wasnt a platform nor a child of platform
return true;

4. In "obj_player" 's step event replace all "place_meeting" with "place_meeting_solid".

As you can see this solution works not only for "obj_platform" but also for all of its child object types.

Edited by Dark Exiler, 13 February 2011 - 11:19 PM.

  • 0

#13 Veyneru

Veyneru

    GMC Member

  • New Member
  • 7 posts
  • Version:Unknown

Posted 19 February 2011 - 06:55 PM

Is this compatible with GM8?
  • 0

#14 shrekboy1

shrekboy1

    GMC Member

  • New Member
  • 116 posts

Posted 03 April 2011 - 10:46 AM

this is a really good engine! The movement is a bit fast, but the supplied creation variables made changing that easy. I definitely recommend this example to anyone wanting to make a fast paced platformer!
Great Job!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users