Ello.
Recently I have been thinking about developing a cooking system, where the player interacts with a “fridge”, takes the “item”, which in this case is the “recipe” and then interacts with some “appliance” and all this is done based on a animation. But … how do I make a system that, when the player touches any of these “items” it performs an animation ??
For example: When he interacts with a stove he play an animation … How do I put it all together? like, the animations of the pan, the player’s hand, probably the door opening …
What is the base of these systems ??
_all TY
I’m going to explain this not in terms of code since i don’t know the greater specifities of what you are trying to do, i am going to give you the theoretical approach I would use to do this…
So for something like this interaction system, I would…
have a proximity prompt or some kind of clickdetector or something be on that refrigerator somewhere and when it’s triggered / clicked have it open the door.
Now when you say “takes an item” this is where it gets a bit trickier.
- for this approach to work and be aesthetically pleasing and make sense, I would have the proximityprompt / clickdetector become nonvisible / inactive and than store the different clickdetectors / proximityprompts inside of the items which will become visible and get connected once the refrigerator doors are open, this is preferential but it’s how i would envision it.
- the way in which i would “store the different (clickdetectors / proximityprompts) in the items” would be in a table that way I could just iterate through the prompts of the items in the fridge and than just make them visible by looping through.
- this can be achieved with object oriented programming or functional… you can pick your poison on that one.
For the systems which an animation is played I would follow a similar ideology as I outlined earlier…
I would again have some sort of prompt / interaction mechanic than once it realizes it’s activated with (for proximityprompts = .Triggered) or (for ClickDetectors = .MouseClick) this would be done on the serverside, than recognize through the parameters of the callback inside of the connections who clicked it than perform your animation, or whatever you want to do with the player being known.
I think it will help me a lot when it comes to researching what to really do, I will study the basics first and then study what I “want”.
Thank you so much, it helped me completely
As I’ve understood you are working in a kitchen setup so after you create it do this:
Insert ProximityPrompts/ClickDetectors in the models you need;
Insert a Script in all the ProximityPrompts/ClickDetectors;
Create the Tools you need and put them in the ReplicatedStorage
In the previous scripts create the trigger function
Trigger functions
These are the functions for the ProximityPrompts and ClickDetectors
ProximityPrompt
script.Parent.Triggered:Connect(function(player)
local tool = game.ReplicatedStorage:FindFirstChild("ObjectiveYouWant"):Clone()
local animation = --Create a variable of the animation you need and play it
tool.Parent = player.Backpack
end)
ClickDetector
script.Parent.MouseClick:Connect(function(player)
local tool = game.ReplicatedStorage:FindFirstChild("ObjectiveYouWant"):Clone()
local animation = --Create a variable of the animation you need and play it
tool.Parent = player.Backpack
end)
Modify the script function as you want.
To create the cookers do the same thing for the scripts bug change the functions, for example change
tool.Parent = player.Backpack with:
player.Backpack:FindFirstChild("NameOfYourTool"):Destroy()
wait(TimeYouWantToCookTheFood)
local tool = --game.ReplicatedStorage:FindFirstChild("ObjectiveYouWant"):Clone()
tool.Parent = player.Backpack