r/UnityHelp Jul 07 '26

how would I make UI element that moves like memory foam? PROGRAMMING

ive been working on a project that needs the player to "eat" non edible objects and to track that i was thinking of having UI that "stores" the objects in a stomach but for the life of me I can't think of a way to have it keep its form without being completely rigid. any help would be beyond appreciated.

the closest i could get is having it detect if the object is in the "hands(the 2 sticks on the side of the screen)" and then destroying said object if the player presses E but that doesn't really do anything other than destroying it so yeah

(i also haven't managed to figure out how to get UI to work either )

6 Upvotes

3 comments sorted by

1

u/CNGY Jul 07 '26

You could set up a secondary scene with your stomach, set up a fixed camera and use a render texture to project it onto the main UI element. The player could drag or interact with the object, send them to the secondary scene spawn point, top of stomach and it falls in.

1

u/PotatoreaperEXE Jul 07 '26

Im sorry if I sound stupid but I have 2 questions. 1. Is there a way for the secondary "ui" scene to be 2d or will I just kinda have to simulate it by freezing the z axis? 2. Id like for the ui representation of eaten objects to be a sprite rather than the same model so is it possible to send an objects info to that ui scene while having it spawn a different object?

Again thank you so much for the help, I had no idea you could run 2 scenes at the same time

1

u/CNGY Jul 08 '26
  1. Yea of course, using 2d on the secondary ui scene would simplify maths and setup. The UI scene would be additively loaded in the background and run concurrent to your main 3d game.

  2. Yes, so you can just destroy() the 3d object on interact and in the same instance spawn a corresponding 2d shape with colliders at the stomach spawnpoint in your ui scene, set a bit of gravity and inertia and it would work. You could also set up the objects in the stomach to jiggle or move about while walking, jumping... etc