Player Getting Stuck In Ground

I

IE Entertainment

Guest
This seems like an easy fix and a novice issue but all of a sudden out of nowhere, the player in my game gets stuck in the ground after a jump is landed. I'm using a variable jump so it only happens after a "light" tap of the jump button. The game had been running fine for many weeks with no issues. Now all of a sudden this happens and I can't figure out why. There does NOT seem to be ANY alteration in my code.

One weird thing did happen. I'm thinking that maybe on accident I hit a button on the keyboard that changed something that I can't get a fix on because when I looked at my room window, for some reason many of the sprites, mainly the ground and walls were shifted slightly out of place.

You guys have any ideas about what I could be missing? Something I'm not considering. Thanks!


Here is the jump and ground collision code im using:

//Check For Ground
if (place_meeting(x, y+1, par_wall)) {
//airjump = 1;
vspd = 0;

//Jumping
if (jump_key) {
vspd = -jspd
}

} else {
//Gravity
if (vspd < 10) {
vspd += grav;
}
if (keyboard_check_released(vk_space)||(gamepad_button_check_released(0,gp_face1)) && vspd <-4) {
vspd = -4;
}
}
 

CloseRange

Member
your collision code isn't the best way to approach collisions. You should be checking if the next position you will be at is a wall, and if so, move directly to the wall instead of to the next position:
Code:
if(place_meeting(x, y+vspd, par_wall)) {
    while(!place_meeting(x, y+sign(vspd), par_wall))
        y += sign(vspd);
    vspd = 0;
}
 
N

NeonBits

Guest
The game had been running fine for many weeks with no issues. Now all of a sudden this happens and I can't figure out why.
I've noticed that when I add new things, GM sometimes behave differently; seems to prefer its "established environment"; it becomes like "printed" in its structure. It's better to manualy clean its cache and temporary files. Yesterday, I did. Then, removed objects. Launched. Added them back. GM didn't see a difference; they were in the room, not in the game. Launched a couple times; same. Coding becomes confusing; you don't know if it'll follow or not; you even doubt your understanding of GM and then find it was fine. On a different note, you could have made a mistake in your code; this can affect the game balance. It can be GM itself. But if you have changed the position of youf objects, maybe you should replace them first before trying anything and look at your code.
 

CloseRange

Member
I've noticed that when I add new things, GM sometimes behave differently; seems to prefer its "established environment"; it becomes like "printed" in its structure. It's better to manualy clean its cache and temporary files. Yesterday, I did. Then, removed objects. Launched. Added them back. GM didn't see a difference; they were in the room, not in the game. Launched a couple times; same. Coding becomes confusing; you don't know if it'll follow or not; you even doubt your understanding of GM and then find it was fine. On a different note, you could have made a mistake in your code; this can affect the game balance. It can be GM itself. But if you have changed the position of youf objects, maybe you should replace them first before trying anything and look at your code.
The Cache has to do with resources, not actual code. The cache is a way to reduce build time so that every sprite and sound and object doesn't have to be re-built every time. Yes it's good to clear the cache every now and then (especially before the final build of the game) but if your experiancing logic errors (like getting stuck in the ground or objects not showing up in the room) this has absolutly nothing to do with the cache and is 99.9% likely the fault of your code or how you implemented the object.
 
N

NeonBits

Guest
The cache is a way to reduce build time so that every sprite and sound and object doesn't have to be re-built every time.
If objects are included and not refreshed, then their codes too; am I mistaking? And for the objects of yesterday, they were simply removed/added manualy in the room.
 

CloseRange

Member
If objects are included and not refreshed, then their codes too; am I mistaking? And for the objects of yesterday, they were simply removed/added manualy in the room.
Yes and no. If the recourse in question is edited in any way (including code) then the cache will re-build that recourse no matter what.
As for removing and re-adding objects into the room manually this won't have any effect unless you accidentally did something to the instance in the room the first time (like how you can modify a creation code of individual instances in the room editor).
 
N

NeonBits

Guest
No matter what.. well, after all that time, maybe it's because I'm on 1.4.1772, but it's not always smooth there, cache included; that's my problem; won't change until it's a new project and people being more positive.
As for removing and re-adding objects into the room manually this won't have any effect unless you accidentally did something to the instance in the room the first time (like how you can modify a creation code of individual instances in the room editor).
You mean if I did something like "with (obja) {image_index = 1;}" in the room creation code, GM won't apply the change of adding/removing the object manualy?
 

CloseRange

Member
No matter what.. well, after all that time, maybe it's because I'm on 1.4.1772, but it's not always smooth there, cache included; that's my problem; won't change until it's a new project and people being more positive.

You mean if I did something like "with (obja) {image_index = 1;}" in the room creation code, GM won't apply the change of adding/removing the object manualy?
Nono when you add an object to the room you can right click it and select 'creation code' to add seperate code for that one instance of that object. It will only apply to that one instance you added to the room.

Also I use 1.4 as well and it's the same thing. Actually it might be different in GM2 for all I know.
 
N

NeonBits

Guest
select 'creation code' to add seperate code for that one instance of that object. It will only apply to that one instance you added to the room.
Ah, yes, sometimes I do this. But not in this case. I prefer to use "room creation code"; it's faster than checking instances one by one. I go "with (objA)" or "with (inst_123)". But I don't think this can affect objects being added or removed.. Anyway, thanks for explaining.
 
@NeonBits, odds are very high that any errors happening are errors within your code, not with the GM cache or anything being bugged. I've used GM for like 15 years and have had like 3 problems that were due to GM itself. Every other problem was me coding badly.
 
N

NeonBits

Guest
Oh, please, I cannot be that bad... ok ok; it can take me days, often more, when adding one thing or two. But levels are done. Yay! I admit, I'm not that good at coding; specialy when not being certain anymore; but, here, it's about removing objects manualy, then adding them back manually, just as a test to find what could be wrong; GM hasn't even noticed; it's in the room, not in the game; I had to clean cache; the reason why I was suggesting to the OP. Kinda heavy to blame my code when it's not even calling instance_destroy, etc. I tell ya, my version of GM is special; Yoyo must have lost their Ai joker prototype. Or someone there has programmed a little something to complicate things. But I guess it's just mistakes when programming; I'm happy of not being coding GM itself; game is already difficult! And staff warned me to not use 1.4.1772; my fault. I'm on it since the beginning, I'm hoping to finish on it; people aren't satisfied with the audio quality and other things, so I prefer to wait.

Well, if you want more, go here
 
Last edited by a moderator:
I

IE Entertainment

Guest
Thanks, guys for all of the feedback. I will dig into my code and double check that I didn't accidentally add a comma somewhere. lol. Thanks!
 
I

IE Entertainment

Guest
I figured out the problem. Somehow...*cough...the code for the vertical collision got "erased"! lol
 
Top