The Introduction
Welcome one and welcome all to my very first Mechanic of the Month review post! Mechanic of the Month is a somewhat laid back exploratory task where we take a game mechanic or idea that we think could hold some merit in being present in our future VR games and projects and work on a small prototype of that mechanic for a month. Then, at the end of the month we (or at least, I) will write a little report about what was accomplished, how, and how it can be improved on in the future.
The Mechanic
So, what mechanic did I decide on for this month? Well, I decided to create a system that allows a held object to contain another object inside of it without the use of parenting so the contained object can be interacted with independently of the first object. In other words, I wanted to make a frying pan that let you put a burger inside of it, and flip the burger without scripted forces. To those unfamiliar with the system I’m using, PuddleJump allows grabbed object to impact non-grabbed objects using CanTransferForce and the PushImpactObject() function. This is because grabbed objects lose their colliders when they are grabbed, as they become extensions of the controllers and don’t play well with Unity physics when grabbed and containing a controller regularly.
This systems works for the most part, but when forces are acting on other forces is where this idea gets wonky, as the video below demonstrates, when trying to hold an object in the air using a held object, the force applied is not strong enough to beat out gravity, so the loose object falls through (albeit slower than normal):
So how exactly did I go about giving these held objects colliders without changing the functionality of the object grabbing system?
The Plan
Simply put, I didn’t give them colliders. Instead, I created a script which takes all of the colliders that would become triggers and moved them to a child object of the grabbed object, which the script also creates. Then, when the object is not grabbed, it turns its triggers back into colliders and disables the child object.
In its current state, all you need to do to is attach the script (which I have given the placeholder name of BabyMaker for the time being) to whatever object you want to hold other objects in, and set up your scene and other objects normally. There is another small caveat that we will discuss in the results.
The Results
So, did it work? Yes! Kinda… It still has a couple of functionality issues but I got the burger to flip, and you can carry regular objects around in a bucket, as demonstrated by this video:
Now this system works in the very sterile environment of doing exactly as expected when using it, however, some interesting situations do occur when more factors are introduced.
Two issues were identified when collecting data for this project. The first being that when you switch the hand that holds an object while there is an object inside of it, there is a frame where the child is deactivated and the regular object has its colliders set to triggers. If the held object is thin enough, this will happen when you go to switch hands:
Problem number 2 ties to teleporting. Not much to say here, only that with this solution there can be some weird effects when teleporting. Most of the time the object just drops from where it was held, as in that instant the thing holding it is no longer there. However in this example the object goes flying off screen, much to my surprise. I don’t really have an explanation for what caused this. Possibly it had something to do with teleporting not actually teleporting you, but moving you very quickly to another location with a fade, but I’m not sure if that is the case. Anyway here’s the video of me testing this and seeing the burger fly off. It’s pretty hard to see, which is another good note for me to use more materials in the future, so everything isn’t just beige:
Another smaller issue is that this system cannot use mesh colliders as Convex Mesh Colliders don’t allow for holes to exists in things like the bucket, but Non-Convex Mesh Colliders don’t allow for Non-Kinematic Rigidbodies. So the best workaround is to build a Compound Collider from Box Colliders. Which looks kinda messy, as you’ll have a lot of box colliders depending on the object, but it works just as well as having the mesh collider.
The Conclusion
So yeah, that’s the first Mechanic of the Month complete. It was cool to be able to make a system that works, albeit not in all cases but enough that I think it holds some merit and use outside of just this exploration. Perhaps in a later MotM I’ll revisit this and fix the teleporting issue, since that seems like the biggest and most immediate problem to me. But for now I’m just glad I got something easily deployable and usable out of this! I don’t think every month will be quite this successful, so I’m glad the first one went well.
As for next month, I was thinking of either doing an exploration of the Oculus Quests’s hand tracking, or work on a system of diegetic inventory management, with the goal being to put object behind your back to store them and then reaching back there to grab them when needed.
Leave a Reply