Rana Lulla
Tags |
---|
Concrete Goals
I wanted to have map/mesh collisions. Ideally with trees and other objects too, but in general just mesh collisions.
What I got done:
We have mesh collisions! There is a video of it on the main page, and it works! It’s using ray casting from (currently) 6 points. This is set up using ECS, and is a part of a component that takes in what the collision points are for a specific entity. So for the players, we have 6 points, one in positive x, y, z, and one in negative x, y, z (the y points are further offset since the player is taller than wide). The points aren’t really accurate to the size of the model, but that’s an easy change and it’s mostly there as placeholder values. I spent most of the time planning out how mesh collisions would work, as we were initially planning some kind of heightmap, but then over the course of a long night where I was sitting in bed attempting to sleep and only saw ray casts and meshes in my head, I realized that doing full mesh collision isn’t that much worse and a lot more expandable. I then wrote up the code for raycasting which was pretty easy since I have done it before, and then worked it in to the game logic (which required a bit of refactoring, but nothing horrible). Then came the debugging of randomly adjusting values to make collisions actually logical, and the inevitable errors I made when writing the code (like one extra raycast that broke everything). Then, Melody worked on bucketing, which was having raycasts only check certain regions of meshes, since it was still exhaustively checking triangles, and implemented that. During this time, I worked out some of the kinks in velocity with meshes (because things were still very slide-y), and things seemed pretty good.
What went differently than expected:
So, we have generalized mesh collisions, that’s great! That means we can collide with anything on the map, right? Uh, no. We can’t collide with any mesh other than the ground. This sounds a little odd; why not? Are the trees and stuff not meshes? Yes, they are, but they are a different mesh. In testing, if we load in the other mesh as a separate file and create a non-mesh floor (by setting velocity to 0 and position to a height), we can collide with the other objects. But if we load in both at the same time, it doesn’t work? There are just random invisible walls (that probably aren’t random, but I’m not sure why they exist). My guess is something with how Assimp loads them is weird (like it’s using some transform node), but I’ve tried simplifying it, and we’ve had Joanne make it a single mesh, but it still loads it as 2 meshes! I’m still not sure how to resolve this one.
What are my goals for next week:
Fix that! I want to have other meshes working correctly; it seems really close, but not quite there yet. I think it’s a loading issue, but it’s hard to test and seems very arbitrary. Also to merge everything into the main branch, and probably raycasting for bullets too. Eventually also game logic, but there are enough just functional systems that need to be integrated first.
What did I learn:
Mesh collisions aren’t actually that bad! It’s definitely a complicated system, and designing it took a long time, but implementation wasn’t horrible. That being said, actually fixing everything to be working may take longer still. There are some easy workarounds we can use to make things mostly functional, and that may just be what has to happen.
Individual morale:
I feel pretty great! I’m super happy with the progress we made this week; collisions are awesome, and it feels so cool to be able to actually interact with the world as we see it.