Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / physics snag

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Oct 2019 07:28 Edited at: 6th Oct 2019 07:40
back in april, i decided to start a platformer based on SpecTre's code and quickly found a snag.

disheartened, i shelved it, until now.

running the following will eventually reveal the issue where the box gets stuck:



it should get "stuck" within the first 30 seconds (usually much sooner).



i've played with sync/vsync, (much) lower velocity, bigger/smaller blocks (compared to "player"), & overlapped shapes; All with the same eventual snag.

any thoughts?

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Oct 2019 08:01 Edited at: 6th Oct 2019 08:16
I believe this is what you are after
SetPhysicsSleeping(0)
https://www.appgamekit.com/documentation/Reference/2DPhysics/SetPhysicsSleeping.htm

Still a slight issue but it does free itself
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Oct 2019 08:24 Edited at: 6th Oct 2019 08:26
Quote: "I believe this is what you are after
SetPhysicsSleeping(0)"

nope.

if you run the code or look at the vid, it's "catching" on the edge of a block (causing miniscule velocity).

Quote: "Still a slight issue but it does free itself"

doesn't free itself, here. i run it, walk away for a few mins, and it's still stuck. either way, it's unacceptable.

fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Oct 2019 08:30 Edited at: 6th Oct 2019 08:42
Quote: "doesn't free itself, here. i run it, walk away for a few mins, and it's still stuck. either way, it's unacceptable."


I see where its catching but the physics sleep command helped for me as it freed itself up quick enough and turning debugoff I can leave it for five minutes and its still going




EDIT well that did work first test and I watched it for five minutes too but now its getting stuck again

I tried this but still needed sleep to 0
if PhysicsRayCastGroup(0,px#,py#,px#,py#+20) = 1 then SetSpritePhysicsVelocity(player,LR*512.0,0.0)
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Oct 2019 08:42 Edited at: 6th Oct 2019 08:45
a quick search showed it's a known issue with box2d. i'll work around it.

and, yeah, i played with the ray, too. on my first go-round, it would also snag when sliding down tiled walls, as well (with no raycasting to the sides/involved).

thanks for trying, fubarpk

smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 8th Oct 2019 20:28
could be the problem is that the raycast is going straight down, i made it a slight diagonal and it no longer seems to get stuck
if PhysicsRayCastGroup(0,px#-1,py#,px#+1,py#+17) = 1 then SetSpritePhysicsVelocity(player,LR*512.0,0.0)
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 8th Oct 2019 22:26 Edited at: 8th Oct 2019 22:31
@smallg, the crooked ray still gets stuck for me (maybe more-so).

my first thought was to add "skid plates" at the bottom corners; just 45 deg lines. it works horizontally but if i add said "plates" to the top corners, too, i realized it would/should still snag vertically when sliding down a wall (which is kinda how i imagine the "crooked ray" is responding - like a pole vault ). if i made sure that the 4-plates "shape" was smaller than any block/tile, it should work (?)

next attempt was to make a "beveled box" around it thinking it would be better than the plates but the player went flying when it hit a snag. it had the same 45 deg corners... i dunno.

then, i tried adding 4 circles for corners which seems to work without a problem:


(the sprite dimensions that i want will be taller than it is wide when using that code)

it seems overkill but i don't think it will affect performance negatively.

i'll keep playing with this but i've unmarked the "solution" for now since i'm still open to other options/thoughts

Attachments

Login to view attachments
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 9th Oct 2019 21:10
yep, i edited the code to run 11 versions at once and now i see it is getting stuck, must have just been getting lucky before because it definitely didn't get stuck in like 30+ runs...
i did some more testing and it doesn't appear to be anything to do with the raycast, if you do a check a variable if the ray is false it still remains at the original value so it looks more like the box is just getting stuck on the corner of the ground or something rather than the velo not being applied.. this is especially noticeable as when you first run the app the player blocks appear to have a gap below them but as time goes on they get lower and lower


with that in mind i found if you push back up against gravity it doesn't get stuck - i left this running for a good 10mins and not 1 got stuck
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu

Login to post a reply

Server time is: 2024-04-20 04:08:58
Your offset time is: 2024-04-20 04:08:58