Bed sleeping animation?

How do I make a player sleep on a bed without having to use a chair seat? Someone had asked me this question so I might as well kill two birds with one stone, and learn it myself.
My issue is that I don’t know where to start. I can’t find any tutorials on this, and the 1 model that I looked at seemed to be cloning and cframing the players body onto the bed. Is there a simpler way of doing this? Thanks.

4 Likes

I’m not sure that there are simpler ways to achieve what you want. Depending on how simple you want it to be there are multiple methods I can think of for making something like this:

Method 1:
As you mentioned you could use a chair seat which is really quick but maybe doesn’t look quite how you want. You could remedy this by having a script detect when a player sits in the seat (and have the seat positioned so the player sits in it upright) and then play your own sleeping animation. You could even make an animation of your character stretching and then lying back into the bed from a sitting position.

Method 2:
If you don’t want to use a chair you can simply use an invisible part and use the .Touched() event to detect when a player touches the bed or gets onto the bed. From there you would have to CFrame their character into position. You could CFrame everything or you could simply CFrame the HumanoidRootPart into position and play an animation similar to the above example.

Method 3:
If you really wanted to go all out you could have a popup prompt when you get near a bed to press a key to lay down in the bed and then another prompt to get out. From there you could use a variety of methods to place the character in the bed similar to above.

Looking back I’m not sure this can be accomplished easily without using either a seat or CFraming unless you do some really crazy stuff with constraints or body forces or something like that. I’ve actually wanted to try make a sleeping animation before but I don’t have a specific use for it so I’d be happy to experiment with an example model when I get the chance and post it here when it’s done.

16 Likes

Ok thanks so much!

You can also use a on-key animation script where like if you press “X” your character sits down

1 Like

I’d recommend trying to anchor the HumanoidRootPart, CFraming it to the bed and playing an animation.

2 Likes

I’ve usually done @EndorsedModel’s method 1 and it works well. Just put a seat in there and call it “Bed”, and when the sitting event fires and the seat is called “Bed”, just play the sleeping animation

4 Likes

Here’s a simple example model I made with animations for both R6 and R15. You’ll just have to load the animations saved in each rig and export them as your own animations and then switch out the animation ID’s that I used to your own ID’s. I tried to name everything and also comment my code so it should be easy to tell how it all works but let me know if you have any other questions :slight_smile:

@ChadTheCreator Um, not sure what you’re implying or quite what to make of that quote.

5 Likes

I’m saying your method is a good one and then explaining to the OP a little if he’s still confused :ok_hand:

1 Like

I am using this now, in 2022. Is it outdated? It no longer works in my game.