GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2013-08-30 06:19:27

Odolwa
Member
Registered: 2013-07-26
Posts: 4

Place_free & Knock Back

I'm using some code which allows my character to be knocked back after jumping on top of a spike.  So far this works, but I'm encountering a problem whereby my character will continue to move into any nearby wall objects once the effect begins.  I know that place_free is normally used to correct this, but the wall clipping glitch still occurs.  I've highlighted this additional code in red.  Can anyone help me out?

Many thanks.


//Spike Knockback
if place_meeting (x,y+10,obj_spike)
{
    if other.x > x
        hspeed = -4
    else
        hspeed = 4

    vspeed = -4
}

if abs(hspeed) > .5
        hspeed *= .8
    else
        hspeed = 0

if place_free(x+hspeed,y)
{
if abs(hspeed) > .5
        hspeed *= .8
    else
        hspeed = 0
}

Offline

#2 2013-09-04 15:42:58

Odolwa
Member
Registered: 2013-07-26
Posts: 4

Re: Place_free & Knock Back

Hmm, no suggestions after all this time...?  It's like a ghost town around here!!

In any case, I finally got a solution for this one so I'll update here.  Replace the red code in the above post as follows:

if (place_free(x+hspeed,y)){}
else
hspeed=0;

Last edited by Odolwa (2013-09-04 15:48:42)

Offline

#3 2013-09-05 08:32:36

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: Place_free & Knock Back

I'm afraid you are right. This forum sees very little activity. I check it most days and saw your question but I didn't have an answer for you.

Thanks for posting the solution.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB