#Moving Boxes

1 messages ยท Page 1 of 1 (latest)

barren yew
#

what i said to do didn't work?

#

@graceful bramble

graceful bramble
#

@barren yew I really don't know, I just restarted the box thing

#

I want to start from the ground up

barren yew
#

what do you have now, and what is not working

graceful bramble
#

I have 3 states, and a box

#

3 empty states

barren yew
#

oh

#

do what you did before

graceful bramble
#

I did 1 states

#

State*

barren yew
#

no i mean

graceful bramble
#

Like I said, I want to start the mechanic from 0

#

Try to understand it better

barren yew
#

what I would do is

graceful bramble
#

Let's talk about the general idea first

#

Like

#

Who moves who and stuff

#

Because I'm truly lost

barren yew
#

in term of state, combine the 3 state together,

#

keep 3

graceful bramble
#

Huh?

barren yew
#

but make the switch statement 3 in 1,

graceful bramble
#

Oh

#

So like

#

Box state

barren yew
#

leave them like this

graceful bramble
#

That's different from player state?

barren yew
#

do you still have the value _box

graceful bramble
#

Yeah

barren yew
#

do you still have the movement of the box inside the event user

graceful bramble
#

No

barren yew
#

box has no code?

graceful bramble
#

Correct

barren yew
#

you can put the same code as yesterday

#

in event user

graceful bramble
#

Ok

#

Like

#

I'm not at my PC rn

#

But what's next?

barren yew
#

Block user_event(0)

    x_speed = oPlayer.x_speed
    
    if place_meeting(x+x_speed,y,oCollision)
    {
        while !place_meeting(x+sign(x_speed),y,oCollision)
        {
            x += x_speed
         }
        x_speed = 0
        oPlayer.x_speed = 0
    }

    x += x_speed

before player movement

if player_state == STATES.PUSH{
  with _box{event_user(0)}
}

after player movement
I assume if there is a wall, player speed will be 0 right?

if player_state == STATES.PULL{
  with _box{event_user(0)}
}
graceful bramble
#

What does after player movement mean?

#

After x+=?

#

Or just before it?

#

Or what?

barren yew
#

yes i know your movement code has a few things, so just put it before that and after that

#

the real goal is to move the block and character to take priority depending on pull or push state

#

if its push, block takes priority, if its pull player takes priority

graceful bramble
#

So where do I put it I don't understand

barren yew
#

before this and after this #help_4 message

graceful bramble
#

So after x+= xspeed

#

Because I did that yesterday and it didn't work

barren yew
#

you didn't have a pull state

graceful bramble
#

I did.

barren yew
#

after i left?

graceful bramble
#

I tried after you went to sleep

#

Ywah

#

I'll try again later though

barren yew
#

what wasn't working?

graceful bramble
#

Honestly I was so done I with it I don't remember

#

But when I'm back coding I'll tag you here

#

And we'll continue

barren yew
#

ok, not sure if ill be here in a few hours

graceful bramble
#

Np

#

I'll try

graceful bramble
#

@barren yew hey

#

so like

#

I added the code

#

now I need to do state transitions

barren yew
#

ok

graceful bramble
#

im working on it

#

ill send what I have

#
    case STATES.PUSH:
    {
        current_physics = boxPhysics
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);
    }
    break;
    
    case STATES.PULL:
    {
        current_physics = boxPhysics
        
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
        
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);
    }
    break
    
    case STATES.BOXIDLE:
    {
        current_physics = idlePhysics
        if x_dir != 0
        {
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
            if x_dir = -x_dir
                StateSwitch(STATES.PULL)
        }
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);
    }    
    break```
#

thats in the player's step

#

all three states

#

x_speed = oPlayer.x_speed


if place_meeting(x+x_speed,y,oCollision)
{
    while !place_meeting(x+sign(x_speed),y,oCollision)
    {
        x += x_speed
    }
    x_speed = 0
    oPlayer.x_speed = 0
}

x += x_speed```
#

thats the user event 0

#
    var _box = instance_place(x+x_facing,y,oBox)
    if player_state == STATES.PUSH
    {
        with _box{event_user(0)}
    }```
#

thats before the movement code

#
    x += x_speed
    if player_state == STATES.PULL
    {
        with _box{event_user(0)}
    }```
#

thats at the end of it

barren yew
#

ok

graceful bramble
#

its pushing, but not pulling

barren yew
#

is that if statement working?

#

put a check in th event user perhaps

#

see if its triggering maybe, with 0 speed

#

sorry im making food so i might not answer right away

graceful bramble
#

ok

#

its not going into the if

#

wait

barren yew
#

are you sure the state pull is working properly

graceful bramble
#

it goes into the user event

#

just not the collision check

#

lemme see again

#

well its the same exact code as push

barren yew
#

you need to put the check outside of the collision check

#

before and after

graceful bramble
#

yeah

#

I did that

barren yew
#

#1234137223549681735 message

#

why is there a x+= there

graceful bramble
#
function Movement()
{
    var _box = instance_place(x+x_facing,y,oBox)
    if player_state == STATES.PUSH
    {
        with _box{event_user(0)}
    }
    
    var grounded = place_meeting(x,floor(y)+1,oCollision)
    var tolerance = 1 + ceil(abs(x_speed));
    
        if place_meeting(x+x_speed,floor(y),oCollision)
        {
            var slope = false
        
            if (grounded) 
            {
        
                for (var i = 1; i <= tolerance; i++)
                {
                    if (!place_meeting(x + x_speed, floor(y) - i, oCollision)) 
                    {
                        slope = true;
                        y -= i;
                        break;
                    }
                }
            
            }
            if !slope
            {
                while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                {
                    x += sign(x_speed)
                }
        
                x_speed = 0
            }
        }
        else
        {
            if (grounded) 
            {
                for (var i = 0; i <= tolerance; i++) 
                {
                    if (place_meeting(x + x_speed, floor(y) + i + 1, oCollision)) 
                    {
                        y += i;
                        break;
                    }
                }
            }
        }



    x += x_speed
    
    if player_state == STATES.PULL
    {
        with _box{event_user(0)}
    }
    
    
    if place_meeting(x,floor(y+y_speed),oCollision)
    {
        while !place_meeting(x,y+sign(y_speed),oCollision)
        {
            y += sign(y_speed)
        }
        
        y_speed = 0
    }
    
    
    y += y_speed

    
    
    

}```
barren yew
#

yeah, you dont want that in movement

graceful bramble
#

oh

#

outside of it then?

barren yew
#

yeah you want movement sandwiched between the 2

graceful bramble
#
var _box = instance_place(x+x_facing,y,oBox)
if player_state == STATES.PUSH
{
    with _box{event_user(0)}
}

Movement()

if player_state == STATES.PULL
{
    with _box{event_user(0)}
}```
barren yew
#

yeah

graceful bramble
#

ok

barren yew
#

so movement() is not happening?

graceful bramble
#

i guess not

#

oh

#

OH

#

its because its a child of oCollision

barren yew
#

player is?

graceful bramble
#

no

#

box it

#

is

barren yew
#

yeah but why is the character unable to move the opposite direction of the box, are you inside the box?

graceful bramble
#

no im facing the box

#

if place_meeting(x+x_speed,floor(y),oCollision)

#

thats the entrance to collision code

barren yew
#

yeah but you'd trying to move the other way

graceful bramble
#

yeah idk

barren yew
#

can you check what x_speed is at before movement when pulling

graceful bramble
#

its zero but ill show debug message

#

ok it accelerates for exactly 3 frames, then it goes to 0

barren yew
#

accelerate?

graceful bramble
#

like

#

it goes for 0.08

#

then 0.16

barren yew
#

oh yeah i see it

graceful bramble
#

then 0.24

#

then 0

#

no no

#

in the video

#

thats when I push

#

that works

#

when I pull its basically 0

barren yew
#

so x_speed is 0 right before movement() when pulling?

graceful bramble
#

no

#

wait

#

what

#

what goes before movement?

#

push or pull

barren yew
#

push

graceful bramble
#

ok good

#

wait why is the second _box not yellow

#

now it is

#

ignore that

barren yew
#

ok, but if you put a show_debug_message(x_speed) right before movement()

#

what does it say

graceful bramble
#

lemme check

#

0.08

barren yew
#

never goes up?

graceful bramble
#

no

barren yew
#

you need to solve that i guess

#

wait

#

its 0.08 or -0.08

graceful bramble
#

show_debug_message("before " + x_speed)

#

0.08

#

also how do I write that?

barren yew
#

shouldn't it be -

graceful bramble
#

yes

#

thats weird

barren yew
#

string(x_speed)

#

so your pull code is wrong

#

so just make it x_speed = 0-Approach(x_speed, x_facing * current_physics.max_speed, amount);

graceful bramble
barren yew
#

see what happens

#

if you're trying to pull going left

#

then yeah, its moving right instead

graceful bramble
#

now it flicker between 0 and -0.08

#
show_debug_message(DrawStateSring())




if player_state == STATES.PUSH
{
    with _box{event_user(0)}
    
}
show_debug_message("before " + string(x_speed))
Movement()
show_debug_message("after " + string(x_speed))
if player_state == STATES.PULL
{
    
    with _box{event_user(0)}
}```
barren yew
#

can you try to put show_debug_message(_box) there at the top, so we can make sure the thing is always registering

graceful bramble
#

just repeats like that

barren yew
#

its always 100042 both on pull and pushing?

graceful bramble
#

yeah

barren yew
#

ok good

#

lets do a quick test

#

at the end of the case for pull, just try to put x_speed = -1;

#

and try to pull to the left

graceful bramble
#

works

#

at -1 speed

#

and pulling to the right does not

barren yew
#

ok

graceful bramble
#

its 0

barren yew
#

well yeah

graceful bramble
#

x_speed = 0-Approach(x_speed, x_facing * current_physics.max_speed, amount);

#

so the prob is here

barren yew
#

yeah

graceful bramble
#

for some weird reason im twiceas fast now

#

without the box and with it

#

like

#

same x_speed

#

but twice

#

god im so confused

barren yew
#

did you remove the x_speed = -1

graceful bramble
#

yea

#

but it has nothing to do with the box

barren yew
#

but we're on the right track

graceful bramble
#

i dont even touch it

#

yeah

#

x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);

#

is bad

#

I need to find a new way to move

barren yew
#

is fps 120 or something

graceful bramble
#

i doubt it

#

I didnt change it myself

barren yew
#

ok

graceful bramble
#

its like my x += x_speed is doubled

#

and so is my y += y_speed

#

i dont call Movement() twice

#

lemme check if I do actually

barren yew
#

i dont know, you did something

graceful bramble
#

wtf

#

yeah

#

I have the whole thing twice

graceful bramble
#

idk why

#

there now its good

graceful bramble
#

still cant pull

#

or push normally now for some reason

#

omg

barren yew
#

you're touching things and i dont know what

#

are you sure you put the 0- on the right one

graceful bramble
#

yeah

#

but I took it off

#

because it doesnt work anyway

barren yew
#

yeah

graceful bramble
#

fuck it

#

ill redo the x_speed approach thing

#

any suggestions?

barren yew
#

well i dont know where you're at now

graceful bramble
#

with a currect_physics struct for each state

#

and the approach thing

#

x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);

#

this for every state

#

most states*

barren yew
#

ok

#

well i dont think its wrong

graceful bramble
#

clearly its not working tho

barren yew
#

its just, you're character is walking a different way

graceful bramble
#

-facing*current_physics?

#

huh

barren yew
#

i need to confirm this

graceful bramble
#

confirm what?

barren yew
#

put show_debug for x_speed after the movement() and after the if pull

graceful bramble
#

ok

barren yew
#

so is it 0.08 then 0

graceful bramble
barren yew
#

put the 0- back in pull case

graceful bramble
barren yew
#

why is it 0 the frame after

#

oh

graceful bramble
#

oh

barren yew
#

its adding 0.08 to that

graceful bramble
#

im so confused

#

its the apporach doing something wrong

barren yew
#

i understand

#

0- is not the solution

graceful bramble
#

yeah

barren yew
#

or maybe it is

#

try this instead

#

x_speed = 0-Approach(abs(x_speed), x_facing * current_physics.max_speed, amount);

#

try that

graceful bramble
#

works

#

if I pull from the right

barren yew
#

both ways?

graceful bramble
#

i push and pull from the right

barren yew
#

only push from left

graceful bramble
#

no

#

left of the box

#

one sec, video

#

entirely different issues wtf

barren yew
#

you're moving out of the way of the box

#

somehow

graceful bramble
#

I think we should start over

#

again

#

maybe with one state again

#

because it worked

barren yew
#

try to make the _box 2 pixel instead

graceful bramble
#

ok

#

ok so

barren yew
#

so x_facing*2

graceful bramble
#

from the left of the box

#

works totally fine

#

idk about collisions

#

but movement is fine from the left

barren yew
#

and right can only pull?

graceful bramble
#

when I pulled from right, the game froze

barren yew
graceful bramble
#

ok now

#

I can push from the right

#

but not pull

barren yew
#

ok

#

its something with the approach

graceful bramble
#

like I said

#

yes

#

lemme remove it

barren yew
#

the thing is

#

im not sure how you have it working for

#

the character is walking backward

#

in reality, is the character walking forward its just the sprite look like its walking backward?

graceful bramble
#

no

#

x_speed = current_physics.max_speed*x_facing

#

with this instead of approach thing

#

pushing from both sides works

#

pulling does not

barren yew
#

max_speed is?

graceful bramble
#
case STATES.PUSH:
    {
        current_physics = boxPhysics
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
        x_speed = current_physics.max_speed*x_facing
    }
    break;
    
    case STATES.PULL:
    {
        current_physics = boxPhysics
        
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
        
        x_speed = current_physics.max_speed*x_facing
    }
    break
    
    case STATES.BOXIDLE:
    {
        if x_dir != 0
        {
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
            if x_dir = -x_facing
                StateSwitch(STATES.PULL)
        }
        x_speed = 0
    }    
    break```
#

0.8

barren yew
#

ok

#

oh i know

#

i was a bit confused by the facin thing

#

but i think i understand

graceful bramble
#

x_facing is this

barren yew
#

x_speed = Approach(x_speed, (0-x_facing) * current_physics.max_speed, amount);

#

try that

graceful bramble
#

if x_dir != 0
x_facing = x_dir

barren yew
#

in pull

graceful bramble
#

oh just in pull?

barren yew
#

x_speed = Approach(x_speed, (0-x_facing) * current_physics.max_speed, amount);

#

only in pull

graceful bramble
#

FLAWLESS

#

finally

#

ok now collision

barren yew
#

i thought your facing was turning around but i looked at the video, saw it wasn't

graceful bramble
#

yeah

#

x_dir is different from x_facing

barren yew
#

ok

graceful bramble
#

COLLISION WORKS TOO

barren yew
#

yeah, thats why i said event_user before and after

graceful bramble
#

right

#

one final thing

#

wait

#

what if I need to put this in the states

#

if x_dir != 0
x_facing = x_dir

#

and I totally forgot?

barren yew
#

for?

graceful bramble
#

no idea

#

but the other thing

#

I forgot

#

one sec

#

oh

#

I need to leave BOXIDLE

#

when pressing the opposite direction

#

ill try something

#

and come back if I need help

barren yew
#

ok

graceful bramble
#

    case STATES.BOXIDLE:
    {
        if x_dir != 0
        {
            
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
            if x_dir = -x_facing
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
        }
        x_speed = 0
    }```
#

works

#

amazing

#

fuck yes

#

lioran you are a god

#

thank you so much

graceful bramble
#

wait

#

ugh

#
    case STATES.PUSH:
    {
        current_physics = boxPhysics
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
            
        if x_dir != 0
        {
            if x_dir = -x_facing
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
        }
        
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, (x_facing) * current_physics.max_speed, amount);
    }
    break;
    
    case STATES.PULL:
    {
        current_physics = boxPhysics
        
        if x_dir = 0
            StateSwitch(STATES.BOXIDLE)
            
        if x_dir != 0
        {
            
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
                else
                    StateSwitch(STATES.WALK)
        }
        
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, (-x_facing) * current_physics.max_speed, amount);
    }
    break
    
    case STATES.BOXIDLE:
    {
        if x_dir != 0
        {
            
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
            if x_dir = -x_facing
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
        }
        x_speed = 0
    }    
    break```
barren yew
#

why is the character turning around?

graceful bramble
#

I press key_right

#

the makes x_dir = 1

barren yew
#

you allows for right and left at the same time?

graceful bramble
#

lemme check

#

but yeah

#

wait no

#

if x_dir != 0

barren yew
#

whats your button check

graceful bramble
#

that should cancle

#

key_right - key_left

barren yew
#

ok

graceful bramble
#

it happens on both sides

#

btw

#

oh wait

#

if x_dir != 0

#

else

#

idle

#

right?

barren yew
#

i guess

barren yew
graceful bramble
#

yeah

graceful bramble
barren yew
#

ok

#

what decides where the character turns around

graceful bramble
#

x_dir = key_right - key_left

#

and

barren yew
#

x_facing = where?

graceful bramble
#

x_speed = Approach(x_speed, x_dir * current_physics.max_speed, amount);

#

x_facing = x_dirif x_dir isnt 0

barren yew
#
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
#

what's key_box

graceful bramble
#

e

#

"E"

#

but see

#

its not pulling

#

when you turn around

#

it still pushes

barren yew
#

yeah

#

just wondering,

#

but you x_facing is being changed

#

and it shouldn't

#

i dont like the lack of {}

graceful bramble
#

lol

#

sorry

#

its just how I write i guess

barren yew
#

yeah, i dont like it, its harder to read, it can lead to mis-use issue

graceful bramble
#

right

#

one sec

barren yew
#

like now i dont even know if the compiller register the else properly for the other if instead

graceful bramble
#
        if x_dir != 0
        {
            if x_dir = -x_facing
            {
                if key_box
                {
                    StateSwitch(STATES.PULL)
                }
                else
                {
                    StateSwitch(STATES.WALK)
                }
            }
        }```
barren yew
#

does looke chaotic when you write it like that

graceful bramble
#

nothing changed

#

still the same

barren yew
#
        if x_dir != 0{
            if x_dir = -x_facing{
                if key_box{
                    StateSwitch(STATES.PULL)
                }else{
                    StateSwitch(STATES.WALK)
                }
            }
        }

i tend to write like this, but i think that's just me

graceful bramble
#

I know

#

lots of people do

#

I dont

#

but it still doesnt work

#

so theres no matter how I write it rn

barren yew
graceful bramble
#

no

barren yew
#

where is this

graceful bramble
#

should I addit?

barren yew
#

no

graceful bramble
#

if each state that needs it

barren yew
#

your x_facing is changing

graceful bramble
barren yew
#

so, what is setting it?

graceful bramble
#

sorry

#

ill look myself

#

in the walk state

#

if changes facing

#
      if x_dir != 0
        {
            
            if x_dir = x_facing
                StateSwitch(STATES.PUSH)
            if x_dir = -x_facing
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
        }```
barren yew
#

#1234137223549681735 message

graceful bramble
#

thats in BOXIDLE

barren yew
#

its clearly changing

graceful bramble
#

yup

#

i know

#

but where is the question

#

idk

#

i think its the if x_dir != 0

#

nope

#

ok in boxidle

#

xdir = 0

#

and facing is 1 for example

#

is should go to walk

#

but it goes to push

#

wait lemme check walk

#
    case STATES.WALK:
    {
        
        if image_index = image_number/2
            audio_play_sound(soundStep,1,false)
        if x_dir != 0
            x_facing = x_dir
        current_physics = walkPhysics
        
        if key_roll
            StateSwitch(STATES.ROLL)
        
        if !on_ground
        {
            prev_max_speed = current_physics.max_speed
            StateSwitch(STATES.FALL)
        }
        
        if x_dir = 0
            StateSwitch(STATES.IDLE)
            
        if key_run
        {
            StateSwitch(STATES.RUN)
        }
        
        if key_jump and on_ground
        {
            prev_max_speed = current_physics.max_speed
            y_speed = -jump_speed
            StateSwitch(STATES.JUMP)
        }
        if key_crouch
            StateSwitch(STATES.CROUCHIDLE)
            
        if _box != noone
            StateSwitch(STATES.BOXIDLE)
            
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);
    }    
    break;```
#

if _box != noone
StateSwitch(STATES.BOXIDLE)

#

I think that does it

barren yew
#

you never go to the walk state though

graceful bramble
#

true

barren yew
#

its, push, boxidle, then push again

#

its never going any other states

graceful bramble
#

yup

#

ok checked

#

problem isnt StateSwitch()

barren yew
#

what did you change, it wasn't doing that earlier

graceful bramble
#

idk man

barren yew
#

you changed things

graceful bramble
#
  if x_dir = -x_facing
{
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
}
#

it never enters here

barren yew
#

i dont understand why this exists

graceful bramble
#

to change between pull, push, idle and walk

barren yew
#

but you turn arround before that happen

#

you added some stuff in the last 15 minutes

graceful bramble
graceful bramble
#

nothing changed

barren yew
#

yeah you started making changes i dont know why

#

was working fine

graceful bramble
#

no it wasnt

#

I tested it right after I said it worked

#

and that happened

barren yew
#

you said you did

#

#1234137223549681735 message

#

i think that's when it started

graceful bramble
#

nvm dude

#

ill keep trying idk

barren yew
#

well it was working, then you told me you had to fix something

#

#1234137223549681735 message

graceful bramble
barren yew
#

yeah i know

#

but im saying around that time

graceful bramble
#

dude nvm what I changed

#

it doesnt work

#

idk what changed to change it back

barren yew
#

i know, but like i said

#

your x_facing is changing outside of the state where it can change

graceful bramble
#

it really isnt

#

i just checked

#

again

barren yew
#

its in the video

graceful bramble
#

I dont set it to anything

barren yew
#

it goes , x_facing:-1 during idlebox, then it goes instantly push state, and facing is 1

#

#1234137223549681735 message

#

look at x_facing and state,

graceful bramble
#

case STATES.BOXIDLE:
{

    if x_dir = x_facing
        StateSwitch(STATES.PUSH)
#

thats where I go to push

barren yew
#

watching it in slow motion

#

x_facing becomes 1 DURING idlebox,

#

at the end of the frame, x_facing is 1 and it is idlebox

graceful bramble
#
    case STATES.BOXIDLE:
    {

            
        if x_dir = x_facing
            StateSwitch(STATES.PUSH)
                
        if x_dir != 0
        {
            if x_dir != x_facing
            {
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
            }
        }
        x_speed = 0
    }    
    break
    ```
#

nothing changes in here

barren yew
#

yeah i know

#

so it goes like this

graceful bramble
#

something happens here

barren yew
#

frame 1: x_dif=0, x_facing=-1, IDLEPUSH
frame 2: x_dif=1, x_facing=1, IDLEPUSH

#

How does this happen?

#

that walk

#

you put a show_debug inside the StateSwitch?

graceful bramble
#

function StateSwitch(_state){
    image_speed = 1
    
    state_timer = 0
    mask_index = sPlayerIdle3
    if _state = STATES.LEDGE
        y_speed = 0
    if _state = STATES.CROUCHIDLE
        mask_index = sPlayerCrouchIdle
    if _state = STATES.CROUCHWALK
        mask_index = sPlayerCrouchIdle
    if _state = STATES.SLIDE
        mask_index = sPlayerCrouchIdle
    if !(_state = STATES.CROUCHIDLE or _state = STATES.CROUCHWALK)
        image_index = 0
    if _state = STATES.JUMP
        audio_play_sound(soundJump,1,false)
    if _state = STATES.LAND
        audio_play_sound(soundLand2,1,false)

    show_debug_message(DrawStateSring())
    player_state = _state
}```
#

there?

barren yew
#

where is that show_debug message

graceful bramble
#

oh

#

its at the end of the step

#

now its at the end of the step and in stateswitch()

barren yew
#

ok, so you try to pull the box and it goes walk for 1 frame?

graceful bramble
#

goes to walk

#

and the idle

#

and then push

#

its like

#

facing doesnt change fast enough

barren yew
#

figure out which stateswitch is setting that

graceful bramble
#

and it still registers _box

barren yew
#

i guess 1 frame is missed in the video perhaps

graceful bramble
barren yew
#

so its doing the else of the if key_box

graceful bramble
#

yeah

#

for 1 frame

#

because im not pressing key_box

barren yew
#

key_box is either 1 or 0?

graceful bramble
#

yeah

#

true or false

#

this is the problem

#

it starts walking before like

#

changing facing?

barren yew
#

how does the player enter and cancel an interaction with a box?

graceful bramble
#

var _box = instance_place(x+x_facing,y-1,oBox)

barren yew
#

ok, so,

#

no i meant player control

#

how is it suposed to behave

#

but...

#

if you hold the button, push and pull works fine

#

but if you release it, it causes that in the video to happen?

graceful bramble
#

if I release the move button

#

it goes to box idle

#

then

#

because im turning around

#

wait

barren yew
#

you showed me the video with 0 context

graceful bramble
#

still in idle

#

turned around quickly

barren yew
#

yeah

#

yeah but my question is somewhere else

#

does this only happen if

graceful bramble
#

im trying 10 fps

barren yew
#

you release key_box during the push?

#

i think you forgot to mention something early on

#

and im trying to clarify that

graceful bramble
#

I dont press key_box at all

#

ever

barren yew
#

so what's key_box for?

graceful bramble
#

to pull

#

       if x_dir != 0
        {
            if x_dir != x_facing
            {
                if key_box
                    StateSwitch(STATES.PULL)
                else
                    StateSwitch(STATES.WALK)
            }
        }```
barren yew
#

ok

graceful bramble
#

so

#

if im moving

#

and I dont look where I move

barren yew
#

you dont need to hold the button to start pushing?

#

you just walk toward the block?

graceful bramble
#

not keybox

#

yes

barren yew
#

ok

graceful bramble
#

again

#

its walking into the block even though Im facing the opposite way

#

ill print facing and xdir

barren yew
#

ok, so the problem arrise if you're not holding the key_box during a turn arround

#

if so, you never told me that

#

i was tyring to debug something entirely different

#

i believe all you need to do

graceful bramble
barren yew
#

yes

#

cause the character is never turning around

graceful bramble
#

its stil registering _box after I turn around

#

oh

#

_box should be with x_dir?

barren yew
#

you need to invert facing at the same time you make state walk during boxidle

graceful bramble
#

ok

barren yew
#

x_facing= -x_facing;
in the else statement along with walk state

#

maybe x_speed = 0;

graceful bramble
#
        if x_dir != 0
        {
            if x_dir != x_facing
            {
                if key_box
                    StateSwitch(STATES.PULL)
                else
                {
                    if x_dir != 0
                        x_facing = x_dir
                    StateSwitch(STATES.WALK)
                }
            }
        }```
#

added this

#

it works now

barren yew
#

you're already checking for x_dir at the top

#

you dont need that extra if statement

#

that should fix it

graceful bramble
#

nowwwww pulling sucks

barren yew
#

how come

graceful bramble
#

i think it goes into PULL before is checks x_dir != x_facing

#

lemme check

#

idk whats wrong

#

it teleports me

#

sometimes

#

not all the time

#

idk whats going on

#

im so tired of this

barren yew
#

x_speed=0 in there perhaps

graceful bramble
#

wait where

barren yew
#
        if x_dir != 0
        {
            if x_dir != x_facing
            {
                if key_box
                    StateSwitch(STATES.PULL)
                else
                {
                    StateSwitch(STATES.WALK)
                    x_speed=0;
                    x_facing = x_dir
                    _box = noone;
                }
            }
        }
#

actually

#

i dont know whats going on in there

#

so i'd put them after

graceful bramble
#

I should add like

#

if _box != noone to everything

barren yew
#

or rather

graceful bramble
#

cuz now this is possible

#

idk what causes it

barren yew
#

when does that happen?

#

i changed the code a bit

#

try that

graceful bramble
#

im in box idlee

#

but the box isnt registered

#

im one pixel off i think

barren yew
#

how is boxidle set?

#

or push

graceful bramble
#

if _box != noone
StateSwitch(STATES.BOXIDLE)

#

if x_dir = x_facing
StateSwitch(STATES.PUSH)

barren yew
#

so you already have one a check for that

graceful bramble
graceful bramble
barren yew
#

show me whole state

graceful bramble
#
    case STATES.BOXIDLE:
    {

        current_physics = boxPhysics
        if x_dir = x_facing
            StateSwitch(STATES.PUSH)
                
        if x_dir != 0
        {
            if x_dir != x_facing
            {
                if key_box
                {
                    StateSwitch(STATES.PULL)
                }
                else
                {
                    StateSwitch(STATES.WALK)
                    x_speed = 0
                    x_facing = x_dir
                    _box = noone;
                }
            }
        }
        x_speed = 0
    }    
    break```
#
    case STATES.WALK:
    {
        
        if image_index = image_number/2
            audio_play_sound(soundStep,1,false)
        if x_dir != 0
            x_facing = x_dir
        current_physics = walkPhysics
        
        if key_roll
            StateSwitch(STATES.ROLL)
        
        if !on_ground
        {
            prev_max_speed = current_physics.max_speed
            StateSwitch(STATES.FALL)
        }
        
        if x_dir = 0
            StateSwitch(STATES.IDLE)
            
        if key_run
        {
            StateSwitch(STATES.RUN)
        }
        
        if key_jump and on_ground
        {
            prev_max_speed = current_physics.max_speed
            y_speed = -jump_speed
            StateSwitch(STATES.JUMP)
        }
        if key_crouch
            StateSwitch(STATES.CROUCHIDLE)
            
        if _box != noone
            StateSwitch(STATES.BOXIDLE)
            
        var amount = x_dir == 0 ? current_physics.brake : current_physics.accel
        x_speed = Approach(x_speed, x_facing * current_physics.max_speed, amount);
    }    
    break;```
barren yew
#

where is the _box

graceful bramble
#

_box = instance_place(x+x_facing,y-1,oBox)

#

second line of step event

barren yew
#

ok

graceful bramble
#

right after player input script

barren yew
#

can you record a video of how it behaves now, cause those screenshot aren't telling me much

graceful bramble
#

ok

#

idk why it teleports

#

but its weird

#

thats a whole other thing

barren yew
#

its doing that before

#

you're somehow inside oBox just slightly

graceful bramble
#

apparntly

barren yew
#

looking for your movement script again

graceful bramble
#
function Movement()
{

    
    var grounded = place_meeting(x,floor(y)+1,oCollision)
    var tolerance = 1 + ceil(abs(x_speed));
    
        if place_meeting(x+x_speed,floor(y),oCollision)
        {
            var slope = false
        
            if (grounded) 
            {
        
                for (var i = 1; i <= tolerance; i++)
                {
                    if (!place_meeting(x + x_speed, floor(y) - i, oCollision)) 
                    {
                        slope = true;
                        y -= i;
                        break;
                    }
                }
            
            }
            if !slope
            {
                while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                {
                    x += sign(x_speed)
                }
        
                x_speed = 0
            }
        }
        else
        {
            if (grounded) 
            {
                for (var i = 0; i <= tolerance; i++) 
                {
                    if (place_meeting(x + x_speed, floor(y) + i + 1, oCollision)) 
                    {
                        y += i;
                        break;
                    }
                }
            }
        }



    x += x_speed
    

    
    if place_meeting(x,floor(y+y_speed),oCollision)
    {
        while !place_meeting(x,y+sign(y_speed),oCollision)
        {
            y += sign(y_speed)
        }
        
        y_speed = 0
    }
    
    
    y += y_speed

    
    
    

}```
#

there

barren yew
#

This line at the top
if place_meeting(x+x_speed,floor(y),oCollision)

#

is returning true

#

but then

graceful bramble
#

remember that does box too

#

oBox is collision

barren yew
#
            if !slope
            {
                while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                {

It's reaching that point

#

it's not checking the same position

#

its checking a whole pixel further

#

do you understand?

#

what is going on

graceful bramble
#

nope

#

oh thats the teleport?

barren yew
#

yes

graceful bramble
#
 if (!place_meeting(x + x_speed, floor(y) - i, oCollision)) 
                    {
                        slope = true;
                        y -= i;
                        break;
                    }```
#

I mean

#

I can add like

#

if placemeeting stuff

barren yew
#

because for some if place_meeting(x+x_speed,floor(y),oCollision) is inside xbox
but while !place_meeting(x+sign(x_speed),floor(y),oCollision) is not, so it moves until it hits the wall

#

that's why it froze earlier, cause you tried to pull right, and went into infinity

graceful bramble
#

if place_meeting(x + x_speed, floor(y) , oCollision)

#

right

#

so i add that place meeting?

barren yew
#

i didn't say to add anything

graceful bramble
#

just asking

barren yew
#

you're having a collision issue

#

because your backup check, does not check the same thing as your original check

#

x+x_speed, while x_speed is perhaps, 0.2

#

then you do, x+sign(x_speed), which will always be 1

graceful bramble
#

ahhhh

#

yeah I thought that'd be an issue

#

so what do I change it to?

#

if not sign

barren yew
#

i dont know, hmm

graceful bramble
#

min(x+x_speed,x+sign(x_speed))

#

I think that

#

then if its lower than 1

#

itll go to that

barren yew
#

you can try

#

well

#

not like that

#

x+min(x_speed,sign(x_speed))

graceful bramble
#

yeah

barren yew
#

that wont work either

#

wait

#

min wouldn't work for

#

below 0

#

so no

graceful bramble
#

min abs

#

?

#

nah

barren yew
#

doesnt work

#

you can't even floor it

graceful bramble
#

yeah

barren yew
#

what's min speed of push and pull

graceful bramble
#

min or max

barren yew
#

min

#

max too i guess

#

.8?

graceful bramble
#

min is 0.08

#

max is 0.8

barren yew
#

ok

graceful bramble
#

because 0.08 is the accel speed

barren yew
#

perhaps a check for movement between -1 to 1

graceful bramble
#

explain?

#

sorry...

barren yew
#

i dont like the idea

graceful bramble
#

but

barren yew
#

maybe it works but

#

ok

#

maybe this

#
            if !slope and abs(x_speed) > 1
            {
                while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                {
                    x += sign(x_speed)
                }
        
                x_speed = 0
            }
#

only different is and abs(x_speed) > 1

#

that's basically preventing whats going on

graceful bramble
#

yeah it helps

#

but

#

now I can walk into oCollision

#

because my speed can be lower than 1 when walking too

barren yew
#

oh yeah, it sets x_speed to 0 during that

#

can the x_speed =0; be outside of that if statement?

graceful bramble
#

uh

barren yew
#

is that important?

graceful bramble
#

i think it is

#

lets check

#

it breaks slopes

#

huh?

#

oh

#

if !slope is one

barren yew
#

wait

graceful bramble
#

and if abs(whatever) is another one?

barren yew
#
            if !slope
            {
            if  abs(x_speed) > 1{
                while !place_meeting(x+sign(x_speed),floor(y),oCollision)
                {
                    x += sign(x_speed)
                }
              }
                x_speed = 0
            }
#

just like that

graceful bramble
#

thatll do it

#

yup

#

I need bug testers

#

to really break the boxes

#

idk what else I can break

barren yew
#

test your stuff all the time

graceful bramble
#

yeha

#

broke it again

barren yew
#

i've not seen your slope yet

#

what happens if you drag the block toward a slope, or on a slope

graceful bramble
#

oh shit

#

fuck that

#

thats not yet

#

first make it work flat

#

anyway

#

my slopes are gonna be stairs

#

so the box wouldnt go up

barren yew
#

is your xBox using movement() to move?

graceful bramble
#

no

barren yew
#

why not

graceful bramble
#

idk

#

lets try

barren yew
#

not super important, just wondering

#

so maybe you can perhaps centralize your movement script

graceful bramble
#

lol

#

so funny

barren yew
#

make sense

graceful bramble
#

yeha

#

but uh

#

the rest works

#

execpt for a bit

barren yew
#

for a bit?

graceful bramble
#

one sec

#

ill see if I can recreate it

barren yew
#

you can pull it up i guess

graceful bramble
#

I would

#

but pulling doesnt work

#

idk why

#

it doesnt move

barren yew
#

just doesnt work up the slope?

graceful bramble
#

now I can pull

#

wtf

barren yew
#

subpixel problem probably

graceful bramble
#

yeah

#

when like

#

going off a slope

#

it puts me in a sub pixel

#

ok so

#

it works

#

i guess

#

maybe

#

sometimes

barren yew
#

was pushing up slope part of the plan?

graceful bramble
#

not really

#

box+slope wasnt the plan at all

barren yew
#

ok

graceful bramble
#

but I can pull up the slope now

#

can I give you the exe to try to break it?

barren yew
#

can you put it on gx for testing?

#

a lot easier that way

graceful bramble
#

oh yeah

#

how do I do that?

barren yew
#

you just switch target, you also need to go to your account

graceful bramble
#

found it

barren yew
#

i've never really used it but i know its possible

graceful bramble
barren yew
#

you can edit stuff on the website i believe

#

such as who can access it and such

graceful bramble
#

whats the url for the website again?

barren yew
#

click the portrait at the top

graceful bramble
barren yew
#

should had jump capability while pushing

graceful bramble
#

yeah

#

agreed

barren yew
#

hmm

graceful bramble
#

hmmmmmmmmmm

#

ok I added like

#

a little padding to the _box check

#

x_facing*2

barren yew
#

seeing an issue, which i think can be solved by just

graceful bramble
#

oh?

barren yew
#

if i get into idlepush

#

and just tap a direction

#

the next push or pull will struggle

#

but i think this can be pixel

graceful bramble
#

pixel?

graceful bramble
barren yew
#

no

#

not that

#

i dont know if its going to work

#

but in boxidle

#

just put
x=round(x);
_box.x=round(_box.x);
Also, you might wanna put
if _box == noone{break}
in all 3 push state

graceful bramble
#

I did like

barren yew
#

you can also put a change state in there as well

graceful bramble
#

if _box != noone

#

do the state

#

else

#

go to idle

#

and it works

barren yew
#

well, im pulling with no blocks next to me

graceful bramble
#

oh

#

well I didnt upload the fixed version yet dumdum

barren yew
graceful bramble
#

yeah I know

#

its fixed now

#

uploading

#

ok thats it for now

#

thank you

#

and

#

uh

#

idk what else

barren yew
#

that includes this? #1234137223549681735 message

graceful bramble
#

no

graceful bramble
barren yew
#

yes but that's not what i want to fix

graceful bramble
#

what

barren yew
#

that's adifferent thing

#

i get stuck inside the block

graceful bramble
#

oh shit

barren yew
#

by a sub pixel

#

just put
x=round(x);
_box.x=round(_box.x);
in box idle at the top, im not sure if it will fix it

graceful bramble
#

what is that supposed to do?

barren yew
#

remove the sub pixel

#

that can happen during push or pull

graceful bramble
#

ok

#

thank you again lioran

barren yew
#

np

#

are you adding it?

graceful bramble
#

added yeah

barren yew
#

new link

graceful bramble
#

oh ok

#

I also rounded y while falling

#

for the bug where you can get into a subpixel after wall sliding

barren yew
#

when hitting the ground?, that's fine

graceful bramble
#

yeah

#

where do I round y?

#

if I put it in the idle state it doesnt round it

barren yew
#

when hitting the ground while falling/jump

#

the pull and push seems pretty good now

#

but that's a slope problem

#

but this would also happen if you tried to push off a ledge

graceful bramble
#

yeah

#

boxes and box states dont have gravity

#

yet

barren yew
#

i think at one point you will need to start processing place_meeting for the x position without looking at subpixel

#

basically putting round on every place_meeting like you did for y

graceful bramble
#

frac or something?

barren yew
#

or floor

graceful bramble
#

of like the floor?

#

ill try to floor

barren yew
#

i see a little of small things that are due to the subpixel

graceful bramble
#

yeah

#

subpixels sucks

barren yew
#

already had a problem because of it

graceful bramble
#

which problem?

#

cant sneak under?

barren yew
#

the teleport thing

graceful bramble
#

oh

#

the jump teleport thing

#

yeah

#

what else can I floor there?

barren yew
#

ignoring the decimal would probably solve every sub pixel problem

graceful bramble
#
    if place_meeting(x,floor(y+y_speed),oCollision)
    {
        while !place_meeting(x,y+sign(y_speed),oCollision)
        {
            y += sign(y_speed)
        }
        
        y_speed = 0
    }
    
    
    y += y_speed```
barren yew
#

only need to ignore it during place_meeting

graceful bramble
#

its already floored in the y collision

#

and it still does the jump teleport

barren yew
#

yeah

#

thing is

#

for x position

graceful bramble
#

oh ok

barren yew
#

floor won't cut it i think

graceful bramble
#

oh?

barren yew
#

because x_speed can be minus or positive

graceful bramble
#

right

barren yew
#

y_speed too but only when going up which doesnt matter

graceful bramble
#

so x_speed - frac?

#

no youre wrong

#

it does matter when going up

#

when you hit the ceiling

barren yew
#

the decimal i mean doesnt matter

graceful bramble
#

oh

#

idk

barren yew
#

since you just hit the ceiling and fall down, even if you're 1 pixel inside the ceiling

graceful bramble
#

then why teleport?

barren yew
#

where is the teleport?

#

while !place_meeting(x,y+sign(y_speed),oCollision)

#

you're not flooring the y by the way

graceful bramble
#

floor(y+sign(y_speed?))

barren yew
#

y of both, eitherway doesnt matter

#

sign never has fraction so

graceful bramble
#

yeah

#

but the y+sign

#

idk

#

i floored both

barren yew
#

ok

#

thing you might have to do

#

here is obscure knowlege

graceful bramble
#

ok

barren yew
#

ceil and floor on 0.1 will become 1 and 0

#

ceil and floor on -0.1 will become 0 and 1

#

make sense?

#

but

#

0.1 div 1, will become 0
-0.1 div 1, will become 0

graceful bramble
#

0.1/1?

barren yew
#

no

graceful bramble
#

whats div

barren yew
#

div is different

#

div always give a non frac result

graceful bramble
#

right

barren yew
#

but

#

when used on number above 0, it acts like a floor

#

and when used on number below 0, it acts like a ceil

graceful bramble
#

oh thats cool

barren yew
#

so i'm wondering if

#

you need to change all your place_meeting to be

#

place_meeting(round(x+x_speed),...)
or
place_meeting((x+x_speed) div 1,...)

#

I think round(x+x_speed) is the right way

#

definitely round

graceful bramble
#

same with y?

#

orjust x?

barren yew
#

no, y leave it at floor

graceful bramble
#

kk

#

place_meeting(round(x + x_speed), floor(y) + i + 1, oCollision))

#

so this for example

barren yew
#

it doesn't really matter for x round or floor i think

#

you can go with floor

graceful bramble
#

ir !place_meeting(round(x)+sign(x_speed),floor(y),oCollision)

#

or this

barren yew
#

yeah, go with floor i say

graceful bramble
#

for x?

barren yew
#

yeah

graceful bramble
#

youre cunfusing me

#

ok