Creating a simulation?

Hi. I’m looking to create a simulation for Characters, whereas they sit in a ‘chair’ and then enter said simulation.

Only issue is, I’m not sure how I would go about doing this as I’ve had issues changing the Player’s Character from one model to another and that causes issues.

Would it be best to create a clone of the Player and keep it placed in the seat - Teleport the main Player elsewhere and return back to the seat upon exiting the simulation?

Any ideas are welcomed as I’m stumped.

1 Like

How it currently works:

https://gyazo.com/4ec9c41ba248072539171a02e1d50a97

You answered your own question.

Clone the character, change its name to get rid of the nametag, and play an idle animation where the cloned character sits/lies.

2 Likes

Why not just to the player back when they exit the simulation? Is the character able to find their self in the simulation?

1 Like

No, they’re not.
But I wanted to keep this feature to give other Players the feel of knowing who’s in the simulator etc.

Oh, so it’s a other player visual. Got ya. In that case, loop through the character, clone all parts of the character (including humanoid for clothing), then parent those to a new model. That worked pretty well for my cutscene I did once. Then, teleport the player.

I just give the player a pseudocharacter to work with. Their real character remains sitting in the chair but their camera and controls are rewired to the new character. A certain value determines whether they are in-simulation or not; if they are, actions are done on the simulated character, otherwise they’re done on the main character. Death of a simulated pseudocharacter rewires everything back to the main character. Death of the main character ends the simulation. Then there’s other weird edge cases to cover for (e.g. leaving).

Somewhat pointlessly complicated but at the very least you can avoid certain behaviours like respawning when the NPC dies. I think it works well and if your game is heavily based on said simulations then you’ll want to take that extra mile to make it work out properly.

Since you don’t have any animation of sitting on the “chair” but rather straight attach the player to it, why not instead of doing that, clone their character and attach that instead? And teleport the real character to the inside of the simulation.

1 Like

That’s how I’ve done it, upon touching it the main Character is immediately moved elsewhere and a fake character is placed on the chair. The Camera is left facing the chair during transition before moving back to the character.

The simulation is client side and placed inside the Camera elsewhere on the map, creating the illusion.

Similar to @colbert2677 - a single ObjectValue determines if the Player is in the Simulation. If so, it attaches to their Player, this allows the script to keep track of if the Player leaves also.

Any changes to the ObjectValue ends the simulation and if the Player dies within the simulation, they’re moved back to the chair after a transition.

This was the easiest way I could do it, but it seems to have worked efficiently.

Just a note that you don’t have to put the map in the camera. If the map parenting code is on the client, you can just move it to the workspace. Other clients won’t see it, nor be able to interact with it - it won’t exist at all on their end.

Case like this is precisely why I go through the trouble of making a pseudocharacter rather than using the actual character. I can make a pretty quick and seamless transition in and out of the simulation without anything actually being affected. Using the actual character would probably be easier though.

In terms of handling assets left by the character when they enter the simulation (assuming you use the actual character), I cover for cases using CollectionService rather than ObjectValues. All up to you, though.

Good luck with your project, sounds interesting.

1 Like

@colbert2677
Following on from what you said - I wish to experiment with your idea of a PseudoCharacter that can be controlled.

However, how would I go about changing all of the controls etc. To suit said character?

Typically, this would involve a fork of the PlayerModule and playing around with it until you get the end result of passing controls and cameras between characters. I can’t remember exactly how it’s done, I’ll need to spend some time working away at a repro if I was to give an answer (something I don’t quite have time for).

The beauty of the PlayerModule though is that its a full Lua implementation of the camera and controls system, which means that it’s possible to pass the controlled character in each module. Just be wary of a few edge cases.

If I ever get the time and create this, I’ll update the post, if someone hasn’t already found that method out by then.