Jump to content


Photo

Glitchy platform movement with hspeed


  • This topic is locked This topic is locked
8 replies to this topic

#1 niiiiick

niiiiick

    GMC Member

  • New Member
  • 35 posts
  • Version:GM:Studio

Posted 21 February 2012 - 11:56 PM

Hi, In my platform game I am using hspeed to move my character in order to utilize friction (I want the character to slide a little when they stop moving). This works fine however when I try colliding with wall objects from the side, the character sticks to the wall a little. My guess is that this has something to do with the event when colliding with the wall object. The code for that event is here:
move_contact_solid(direction,12);
vspeed = 0;

Please let me know what I'm doing wrong/How to fix it.
  • 0

#2 @Alex@

@Alex@

    Retired GMC Reviewer

  • Reviewer
  • 3143 posts
  • Version:Unknown

Posted 22 February 2012 - 12:02 AM

Yes a very advanced problem...* You're getting stuck in the wall because you are going fast enough to intersect with the wall before the collision is detected. THere a numerous approachs to solving this and I think you'd benefit from searching the tutorials forum for a Platformer example or two. There are some very good ones and a decent example could potentially help you with other common problems like this.


*Po's Pink , A.k.a sarcasm
  • 0

#3 Lotias

Lotias

    GMC Member

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

Posted 22 February 2012 - 12:14 AM

Instead of the collision event, place this in the step event:
if !place_free(x+vspeed,y)
 {move_contact_solid(direction,speed)
 hspeed=0};

This should solve it.
  • 0

#4 NicroGames

NicroGames

    GMC Member

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

Posted 22 February 2012 - 12:15 AM

Why not create your own speed variables if hspeed gives you problems? It is totally possible to make custom friction (e.g. very easy)

Spoiler

  • 0

#5 niiiiick

niiiiick

    GMC Member

  • New Member
  • 35 posts
  • Version:GM:Studio

Posted 22 February 2012 - 12:20 AM

This should solve it.


This causes the character to fall through the ground.
  • 0

#6 Lotias

Lotias

    GMC Member

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

Posted 22 February 2012 - 12:21 AM

Is the ground a solid object?
  • 0

#7 niiiiick

niiiiick

    GMC Member

  • New Member
  • 35 posts
  • Version:GM:Studio

Posted 22 February 2012 - 12:22 AM

Is the ground a solid object?


Yes.
  • 0

#8 Lotias

Lotias

    GMC Member

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

Posted 22 February 2012 - 01:07 AM

Try changing the "speed" to hspeed.
  • 0

#9 Harmonex

Harmonex

    GMC Member

  • GMC Member
  • 56 posts
  • Version:GM:HTML5

Posted 09 March 2012 - 05:54 PM

Sorry for the several-week bump, but I had this problem, too. Reading this thread helped me figure it out. Just make two of those events: one for vertical, one for horizontal.

if !place_free(x+hspeed,y)
{
    move_contact_solid(direction,speed) ;
    hspeed=0;
}

if !place_free(x,y+vspeed)
{
    move_contact_solid(direction,speed) ;
    vspeed=0;
}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users