Unnamed object/person inflation game

Thread for a game I’m making based around the concept of having several different types of inflation that a character/object can have. Here are the inflation types planned, from lightest to heaviest:

Helium (self explanatory) the Character/object floats a certain distance above the ground. This distance is determined by their “level” of inflation, to keep things easy for coding.

O2: the Character/object is far lighter, making them jump higher, fall slower, and stop faster, as well as making objects far easier to push.

Normal: No inflation.

Water: The Character/object is far heavier, but also larger, making it easier to jump on said objects, and making the character sink in water, when in water, a character will slowly increase in level until they are maxed out. Jump height is lowered, as is speed, and it takes longer to stop, but due to the increased mass, some objects may be pushable in this state.

Fat: This only works for Characters. It’s far heavier, like water, but you can float on water, speed and jump height will decrease as time goes on, and the character will only lose weight by transitioning to the next/previous level.

So far I have an MVP (Minimum Viable Product), involving a placeholder capsule object, a ground plane, a death plane, a static platform, a light platform, and two heavy platforms. The heavy platforms can currently be O2 inflated through key presses as a placeholder method until I can figure out how to limit it.
I’m going to include a VERY short clip of testing the inflation out here: https://youtu.be/TNlcR_to8Xg

I will continue working on it for a while today, with a few breaks as needed.

4 Likes

Update 1/7/2021
Just added in placeholder physics for “water inflation” on the “light” cube. (light blue)
Will now figure out how to fetch the mass of an object, so I can base increments off of that. May also make a script who’s sole purpose is to allow the other codes to draw values from it.

looks interesting!
If you need (wg related) assets you can contact me on discord or look for bucculentus on the forum.

Ye caught me attention laddie. I’ll watch yer progect grow.

Alright, cool, I’ll keep that in mind, thank you! I’ll probably need some later on, after I’m done using the placeholders from Yttreia’s model pack.

2 Likes

Currently, I’m having a pretty big issue; I’m trying to find the mass of an object to set as a “default” mass, so I don’t have to make new code every time I add in an object that’s bigger than what I currently have. Apparently nobody in the history of mankind has EVER done this specific function before, because I cannot for the life of me find any information on how to pull the mass data out of the game engine.

In reality water weighs more than fat. In fact fat floats in water because it is less dense.

I may change this order in game, my only thought process is since I plan to have this be the “heavy that can float”, I wanted to give it something that helps set it apart further, I.E. being more dense means the player would be able to push blocks more easily.

I’m not 100% sure what you mean by this, but wouldn’t the default mass just be a single unit of the measurement of mass used by the engine? Or do you mean a default density that will automatically apply mass to objects of any size? In which case it probably isn’t possible, as most games with a physics engine just do it the hard way and assign a mass to each and every object, and the main way they streamline this is by using the same object multiple times.

It’s hard to explain, but I’ll try to describe it.
I’m setting the mass of each object on the engine side of things, right? So for example, I have a cube that’s the size of the player at let’s say 20 mass, and I have a cube twice that size at 50. I want to multiply these masses by a modifier in code when I inflate them, but I want to use the same script for each, which currently I can’t do. (let’s say since I don’t have it open in front of me the script is something like “ObjHeavyInf” since these are objects meant to be inflated before they can be moved)

Currently I specifically have to set mass in code through rb.mass before I can change it, and can only do that by straight up changing the value manually as well, but what I WANT to do is have the code find the value set in the engine (which always exists at start up, even when I’m not setting the value IN the code) at startup, I then want it to assign THAT to an empty float/integer value (set as defaultMass so I know what it is when I go through code, this is a LOCAL value that is drawn only by the script on the object)
This number becomes the “default” that the code references when an object is returned to it’s normal state, and is the number that is multiplied and assigned as the new mass value whenever I inflate it.

In other words, I need some way to tell the code that the mass is “x” without making a new script with new code or a lookup table to manually put the number in, to streamline asset/prefab creation.

So it would eventually look like this (keep in mind this isn’t C#, or really ACTUAL code, this is just an example of what I WANT the code to do):

Engine: Mass is “x” (rigidbody tab)

Code: Finds Rigidbody Mass on the object is is assigned to, which is “x”
defaultMass = “x”

If base size is needed, rb.mass = “defaultMass(x)”
If size 1 is need, rb.mass = “defaultMass(x)X.75f”
If size 2 is needed, rb.mass = “defaultMass(x)X.5f”
If size 3 is needed, rb.mass = “defaultMass(x)X.25f”
If size 4 is needed, rb.mass = “defaultMass(x)X.1f”
(X = times cause I don’t wanna make it all italics)

Meaning I could apply the code to an object with a mass of 20(x=20), and one with a mass of 50(x=50), set them both to stage 2, and they would return with 10 or 25 respectively without duplicating the script.

Figured I should post an update, just made a background asset for the game:

It has four animations that will continuously play in a loop.

So, maybe I’m still not understanding, but you want all objects to have their own default mass, and to then manipulate that mass value, while still being able to reference that default mass for further manipulation later in the level? If so, then I would assume that all you would need to add to each object is the defaultMass value you mentioned, that then gets called (or referenced, or whatever the term is, I don’t remember C++ as well as I do Java) by the mass code you outlined, so that rb.mass can be set when the objects are loaded.
First, though, I have realized I have made an assumption that I need to clear up: is each level being treated as its own separate thing, with each object saved in its place, or does the code ‘build’ each level by creating and placing copies of objects you’ve defined? Because there is a major difference in how to go about things based on which of those methods you are using.
If you want the engine to assign that defaultMass value for whenever you make a new object (and not a copy of an existing object), that might be a bit more challenging, if not impossible. As I said in my previous post, most engines require you to manually define a new object’s values (which is why copying an object already defined and manipulating it is easier than making a new object). The best you might be able to do is to copy-and-paste a large portion of the code from an existing object.
Overall, I would advise that, to cut down on the number of objects you need to make, just make the code that ‘builds’ the level call a very small number of objects and then manipulate their size, weight, color, etc. in the code, rather than have a hundred different objects with their own stats. it means more code, and possibly longer level load times, but it makes your job a bit easier. Try to only make a new object if its characteristics are too different from all existing objects to be able to transform one of them into it (like if you need a cylinder or a triangular prism instead of a rectangle.

Well, what I want to do is set maybe 3-6 different prefab inflatable objects (3 of each “density” class of heavy or light), but I want to use the same code for all of them so that I don’t end up with 6 different codes, PLUS unique objects like spheres or staircases, or triangular prisms, etc. etc., so I want to be able to make the object, define it’s weight in the Rigidbodies tab, and have the code directly reference THAT value for Rigidbody, so I can then have six different prefab assets with different masses, with those six assets sharing four separate codes. (including the new collision code I made to ensure that the player is actually touching an inflatable object before allowing it to be inflated)

So I want to manually assign the mass values, but I want to do it without changing the script for each new object.

…I don’t know if that makes it more or less confusing.

Possibly make a function that calculates the newly given mass with the mass of x and a multiplier as parameters?

I’m not great at C++ so this may be useless.

Then you just init the masses you want and call on the function to calculate their new mass?

Hmmm, sounds like it’d work. How exactly would I write that in code, though?

well im not sure how to do it in C++

but its like

function name (parameter 1, parameter 2)
value = parameter 1 * parameter 2 (or whatever the formula you are working with is)
return value

then when you go to set the mass of the various things

say Person1 mass = function (parameter1 (im assuming default value for this), parameter2 (the multiplier)

and then when you call on person1mass as a variable, it’ll give you the edited value.

hopefully that makes some sense.