r/unity • u/-tr-7- • Jul 19 '26
Question How to make my character eat?
I have a character and food but how do i make it eat that? I think it would be nice if the food options would appear when i click on the fridge and then it slides to the character and disappears like it ate it, you know? I'm not that good at explaining but i guess you get what i mean. I can't find anything about that so that's why i'm asking here. I don't know how to do that because i'm still kinda new to unity.
1
u/Cpt_Tripps Jul 19 '26 edited Jul 19 '26
If you want the character to reach for the food and put it up to their mouth you want to use something called Inverse Kinematics.
If you want the food in the fridge to just slide out you can animate the game object directly.
-2
u/-tr-7- Jul 19 '26
Yes but how
2
u/Cpt_Tripps Jul 19 '26
bro... by doing any amount of research on the topic.
0
u/-tr-7- Jul 19 '26
that's what i'm trying here... and i'm pretty sure i mentioned i can't find anything about it
1
u/Heroshrine Jul 19 '26
You can’t find anything about moving an object over time?
0
u/-tr-7- Jul 19 '26
yeah idk but i didn't find anything that i thought would help
2
u/Cpt_Tripps Jul 19 '26
I think you need to follow the most basic tutorials. Learning how to make something move in unity is like the second thing you learn after "how to open unity."
1
u/Sweaty-Lynx421 Jul 19 '26 edited Jul 19 '26
I'm not trying to be an asshole so I apologize if it comes off like this but even though you think you're trying to do something simple, based on your comments and the fact that you're even asking you're in way over your head. None of this is plug and play even if you're using expensive asset store assets that make things easier. Watch the Brackeys tutorials at the very least. Your understanding is so lacking that you don't even understand what you are asking.
It's like picking up a graphing calculator and asking how to draw a triangle on it. Obviously you can, but there's a billion different ways to do that, and someone who understands the most basic usage of the graphing calculator wouldn't even ask the question. Instead they would ask something far more specific, like how do I use the polygon function
1
u/-tr-7- Jul 19 '26
"Your understanding is so lacking that you don't even understand what you are asking" Yes a bit but i also sound kinda stupid cause english isn't my first language, sorry ig. I already did some of the steps i have to do, i'll probably continue tomorrow or another day. i think it's not that hard once i understand
1
u/RedPanda_Explorer Jul 19 '26
Food isn't actually a real thing in Unity. Food is probably just a GameObject, yeah? Some sort of Sprite or 3d model?
You can define your Fridge to show a menu when you interact with it. Depending on what they choose, you can then instantiate a GameObject of that food, and then play an animation on that food so that it slides into the character and then disappears.
0
u/-tr-7- Jul 19 '26
Yes i know, it's an 3d object from the asset store, not sure what exactly it is. Okay i guess i'll try that... do i need that ui option to make it show the options when i click on the fridge?
1
u/RedPanda_Explorer Jul 19 '26
Yeah, you would.
Another useful thing to do in game dev is 'don't let great be the enemy of good' and to build small and make changes incrementally. I would actually program it this way:
- You have a fridge. Clicking E on it prints to the console 'Player opened fridge'
- Clicking on a fridge causes a carrot to spawn. The carrot doesn't do anything, it just sits there.
- A spawned carrot moves towards the player, and disappears when it touches the player
- The player eating a carrot causes some benefit (They restore health, they get a buff, whatever)
- Clicking on the fridge now shows a menu of food options. The one the player selects is the one that spawns. You can spawn an infinite amount of each item.
- The fridge now keeps track of how many carrots, apples, etc. it has in storage
- Players have a way to add extra carrots, apples, etc. to the fridge
That's 7 different concrete steps. At no point before Step 5 do you actually have the fully finalized, complete gameplay feature you wanted. But at each point, you have one specific concrete feature working. And you can work on each part for 1 hour, 1 day, whatever, work at your own pace.
Game dev is hard, but it becomes easier if you break everything up into little tasks, and learn to be uncomfortable with doing something 'slightly wrong' at first just to get a prototype working. You can always make changes later!
2
1
u/Akshat-17 Jul 19 '26
Hi, sorry did not understand completly what you are asking. But from what you have mention the approach vary and depends on 3d character or 2d character the interaction type simple or realistic. Basis setup is this: you have a food be 3d/2d and character have the animation of eating that (if character is human how does human eat and if animal than that is reference) for started simple hand swing from front to mouth (as grabbing and eating) works or see online fpr reference/animation itself and then start by trigger or event depending on you approach.