#Moving Boxes
1 messages ยท Page 1 of 1 (latest)
@barren yew I really don't know, I just restarted the box thing
I want to start from the ground up
what do you have now, and what is not working
no i mean
what I would do is
Let's talk about the general idea first
Like
Who moves who and stuff
Because I'm truly lost
Huh?
but make the switch statement 3 in 1,
leave them like this
That's different from player state?
do you still have the value _box
Yeah
do you still have the movement of the box inside the event user
No
box has no code?
Correct
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)}
}
What does after player movement mean?
After x+=?
Or just before it?
Or what?
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
So where do I put it I don't understand
before this and after this #help_4 message
you didn't have a pull state
I did.
after i left?
what wasn't working?
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
ok, not sure if ill be here in a few hours
@barren yew hey
so like
I added the code
now I need to do state transitions
ok
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
ok
its pushing, but not pulling
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
are you sure the state pull is working properly
it goes into the user event
just not the collision check
lemme see again
well its the same exact code as push
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
}```
yeah, you dont want that in movement
yeah you want movement sandwiched between the 2
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)}
}```
yeah
so movement() is not happening?
player is?
yeah but why is the character unable to move the opposite direction of the box, are you inside the box?
no im facing the box
if place_meeting(x+x_speed,floor(y),oCollision)
thats the entrance to collision code
yeah but you'd trying to move the other way
yeah idk
can you check what x_speed is at before movement when pulling
its zero but ill show debug message
ok it accelerates for exactly 3 frames, then it goes to 0
accelerate?
oh yeah i see it
then 0.24
then 0
no no
in the video
thats when I push
that works
when I pull its basically 0
so x_speed is 0 right before movement() when pulling?
push
ok, but if you put a show_debug_message(x_speed) right before movement()
what does it say
never goes up?
no
shouldn't it be -
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);
see what happens
if you're trying to pull going left
then yeah, its moving right instead
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)}
}```
can you try to put show_debug_message(_box) there at the top, so we can make sure the thing is always registering
its always 100042 both on pull and pushing?
yeah
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
ok
its 0
well yeah
x_speed = 0-Approach(x_speed, x_facing * current_physics.max_speed, amount);
so the prob is here
yeah
for some weird reason im twiceas fast now
without the box and with it
like
same x_speed
but twice
god im so confused
did you remove the x_speed = -1
but we're on the right track
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
is fps 120 or something
ok
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
i dont know, you did something
this
idk why
there now its good
you're touching things and i dont know what
are you sure you put the 0- on the right one
yeah
well i dont know where you're at now
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*
clearly its not working tho
its just, you're character is walking a different way
i need to confirm this
confirm what?
put show_debug for x_speed after the movement() and after the if pull
ok
so is it 0.08 then 0
put the 0- back in pull case
oh
its adding 0.08 to that
yeah
or maybe it is
try this instead
x_speed = 0-Approach(abs(x_speed), x_facing * current_physics.max_speed, amount);
try that
both ways?
i push and pull from the right
only push from left
I think we should start over
again
maybe with one state again
because it worked
try to make the _box 2 pixel instead
so x_facing*2
from the left of the box
works totally fine
idk about collisions
but movement is fine from the left
and right can only pull?
when I pulled from right, the game froze
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?
no
x_speed = current_physics.max_speed*x_facing
with this instead of approach thing
pushing from both sides works
pulling does not
max_speed is?
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
x_facing is this
x_speed = Approach(x_speed, (0-x_facing) * current_physics.max_speed, amount);
try that
if x_dir != 0
x_facing = x_dir
in pull
oh just in pull?
x_speed = Approach(x_speed, (0-x_facing) * current_physics.max_speed, amount);
only in pull
i thought your facing was turning around but i looked at the video, saw it wasn't
ok
COLLISION WORKS TOO
yeah, thats why i said event_user before and after
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?
for?
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
ok
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
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```
why is the character turning around?
you allows for right and left at the same time?
whats your button check
ok
i guess
that's x_dir?
yeah
nope didnt change anything
x_facing = where?
x_speed = Approach(x_speed, x_dir * current_physics.max_speed, amount);
x_facing = x_dirif x_dir isnt 0
yeah
just wondering,
but you x_facing is being changed
and it shouldn't
i dont like the lack of {}
yeah, i dont like it, its harder to read, it can lead to mis-use issue
like now i dont even know if the compiller register the else properly for the other if instead
if x_dir != 0
{
if x_dir = -x_facing
{
if key_box
{
StateSwitch(STATES.PULL)
}
else
{
StateSwitch(STATES.WALK)
}
}
}```
does looke chaotic when you write it like that
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
I know
lots of people do
I dont
but it still doesnt work
so theres no matter how I write it rn
is this allowed to execute while in any push state?
no
where is this
should I addit?
no
if each state that needs it
your x_facing is changing
so, what is setting it?
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)
}```
#1234137223549681735 message
thats in BOXIDLE
its clearly changing
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
you never go to the walk state though
true
what did you change, it wasn't doing that earlier
idk man
you changed things
if x_dir = -x_facing
{
if key_box
StateSwitch(STATES.PULL)
else
StateSwitch(STATES.WALK)
}
it never enters here
i dont understand why this exists
to change between pull, push, idle and walk
from here
well it was working, then you told me you had to fix something
#1234137223549681735 message
i didnt add this
i know, but like i said
your x_facing is changing outside of the state where it can change
its in the video
I dont set it to anything
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,
case STATES.BOXIDLE:
{
if x_dir = x_facing
StateSwitch(STATES.PUSH)
thats where I go to push
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
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
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?
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?
oh
its at the end of the step
now its at the end of the step and in stateswitch()
ok, so you try to pull the box and it goes walk for 1 frame?
goes to walk
and the idle
and then push
its like
facing doesnt change fast enough
figure out which stateswitch is setting that
and it still registers _box
i guess 1 frame is missed in the video perhaps
so its doing the else of the if key_box
key_box is either 1 or 0?
yeah
true or false
this is the problem
it starts walking before like
changing facing?
how does the player enter and cancel an interaction with a box?
var _box = instance_place(x+x_facing,y-1,oBox)
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?
if I release the move button
it goes to box idle
then
because im turning around
wait
you showed me the video with 0 context
im trying 10 fps
you release key_box during the push?
i think you forgot to mention something early on
and im trying to clarify that
so what's key_box for?
to pull
if x_dir != 0
{
if x_dir != x_facing
{
if key_box
StateSwitch(STATES.PULL)
else
StateSwitch(STATES.WALK)
}
}```
ok
ok
again
its walking into the block even though Im facing the opposite way
ill print facing and xdir
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
you need to invert facing at the same time you make state walk during boxidle
ok
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
you're already checking for x_dir at the top
you dont need that extra if statement
that should fix it
nowwwww pulling sucks
how come
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
x_speed=0 in there perhaps
wait where
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
or rather
if _box != noone
StateSwitch(STATES.BOXIDLE)
if x_dir = x_facing
StateSwitch(STATES.PUSH)
so you already have one a check for that
in walk state
in box idle state
show me whole state
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;```
where is the _box
ok
right after player input script
can you record a video of how it behaves now, cause those screenshot aren't telling me much
apparntly
looking for your movement script again
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
This line at the top
if place_meeting(x+x_speed,floor(y),oCollision)
is returning true
but then
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
yes
if (!place_meeting(x + x_speed, floor(y) - i, oCollision))
{
slope = true;
y -= i;
break;
}```
I mean
I can add like
if placemeeting stuff
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
if place_meeting(x + x_speed, floor(y) , oCollision)
right
so i add that place meeting?
i didn't say to add anything
just asking
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
ahhhh
yeah I thought that'd be an issue
so what do I change it to?
if not sign
i dont know, hmm
min(x+x_speed,x+sign(x_speed))
I think that
then if its lower than 1
itll go to that
yeah
yeah
what's min speed of push and pull
min or max
ok
because 0.08 is the accel speed
perhaps a check for movement between -1 to 1
i dont like the idea
but
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
yeah it helps
but
now I can walk into oCollision
because my speed can be lower than 1 when walking too
oh yeah, it sets x_speed to 0 during that
can the x_speed =0; be outside of that if statement?
uh
is that important?
wait
and if abs(whatever) is another one?
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
thatll do it
yup
I need bug testers
to really break the boxes
idk what else I can break
test your stuff all the time
i've not seen your slope yet
what happens if you drag the block toward a slope, or on a slope
this is it
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
is your xBox using movement() to move?
no
why not
not super important, just wondering
so maybe you can perhaps centralize your movement script
make sense
for a bit?
you can pull it up i guess
just doesnt work up the slope?
subpixel problem probably
yeah
when like
going off a slope
it puts me in a sub pixel
ok so
it works
i guess
maybe
sometimes
was pushing up slope part of the plan?
ok
you just switch target, you also need to go to your account
found it
i've never really used it but i know its possible
whats the url for the website again?
click the portrait at the top
should had jump capability while pushing
hmm
seeing an issue, which i think can be solved by just
oh?
if i get into idlepush
and just tap a direction
the next push or pull will struggle
but i think this can be pixel
pixel?
this didnt fix the tapping issue
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
I did like
you can also put a change state in there as well
well, im pulling with no blocks next to me
yeah I know
its fixed now
uploading
ok thats it for now
thank you
and
uh
idk what else
that includes this? #1234137223549681735 message
no
this
yes but that's not what i want to fix
what
oh shit
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
what is that supposed to do?
added yeah
new link
oh ok
I also rounded y while falling
for the bug where you can get into a subpixel after wall sliding
when hitting the ground?, that's fine
yeah
where do I round y?
if I put it in the idle state it doesnt round it
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
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
frac or something?
or floor
i see a little of small things that are due to the subpixel
already had a problem because of it
the teleport thing
ignoring the decimal would probably solve every sub pixel problem
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```
only need to ignore it during place_meeting
oh ok
floor won't cut it i think
oh?
because x_speed can be minus or positive
right
y_speed too but only when going up which doesnt matter
so x_speed - frac?
no youre wrong
it does matter when going up
when you hit the ceiling
the decimal i mean doesnt matter
since you just hit the ceiling and fall down, even if you're 1 pixel inside the ceiling
then why teleport?
where is the teleport?
while !place_meeting(x,y+sign(y_speed),oCollision)
you're not flooring the y by the way
i am totally new to programming let alone gamemaker studio 2
i am learning from shaun spalding's videos too.
and i came across this code in his video. i think i know what the code does (it is to subtract decimal part of the number??).
but i dunno why it is necessary.
hsp += hsp_frac; //why...
floor(y+sign(y_speed?))
ok
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
0.1/1?
no
whats div
right
but
when used on number above 0, it acts like a floor
and when used on number below 0, it acts like a ceil
oh thats cool
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
no, y leave it at floor
kk
place_meeting(round(x + x_speed), floor(y) + i + 1, oCollision))
so this for example
yeah, go with floor i say
for x?
yeah