Fun with physics


Psych, working with physics today was anything *but* fun:

  1. add_shape was not behaving the way I was expecting it to, and
  2. set_shape does indeed let you change the shape, but you lose the shape offset data (which is encoded in the parent of the shape, which is thrown away), so the shape is always at (0, 0)

Translation: when trying to get the player to "crawl" under an obstacle, it proved...surprisingly challenging. My original plan was to change the player's collision shape so that it was physically smaller and could fit under the branch obstacle's collision shape. To do this I clear all the collision shapes currently on the player and then add back just the ones I want. However, the add_shape bit basically wasn't working at all, so the player would just uh, fall through the floor. Neat.

So instead of clearing all the shapes, I thought I'd just change the standing shape to the crawling shape (which is basically the same but half as tall). However this didn't really work either, because as mentioned above the shape is just "I'm a rectangle that's X wide and Y tall", and when it gets added to the player, it gets added right at (0, 0). So while the player wouldn't fall all the way through the floor, their feet would now be half-underground.

Ultimately, I decided this physics shape-swapping angle wasn't going to pan out. So I did the next most obvious thing: when clearing the challenge word for the branch obstacle, just straight up remove the branch obstacle's collisions entirely. This is nice too because now the player can't possible get stuck on the branch object since it's just gone. The visual component is still there, and the light-blocking component is still there, but the rest is basically gone. This will become a problem if anything else needs to interact with the physics object of the obstacle, but then I can just use collision masking magic to ensure that the player can get by but perhaps nothing else.

Phew! Still, at least it's working now. Kinda!

Files

Going Home (Windows, latest) 17 MB
Version 4 33 days ago
Going Home (Linux x64, latest) 31 MB
Version 3 33 days ago
Going Home (Mac OSX, latest) 20 MB
Version 3 33 days ago

Get Going Home

Download NowName your own price

Leave a comment

Log in with your itch.io account to leave a comment.