- Home /
Question by
Igor_S_16 · Dec 19, 2014 at 11:19 PM ·
instantiatecharacterswitch
Instantiate a prefab and switch character control to it
I want to create a script with c# that do this: - you start moving a cube and when you press 'E' block the character - instantiate a prefab with the controller - control the second cube
i have to start:`
public class Switch : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.E){
SwitchFunction();
}
}
void SwitchFunction () {
}
}`
Comment
Instantiate the second cube, which should have an active version of your cube controller script on it, while disabling the current(1st cubes) controller script.
And possibly a similar switch for your camera.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174441im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Checking if object intersects? 1 Answer
Destroying & Then Spawning Quickly 1 Answer
character switching problem 1 Answer
switch character 1 Answer
switching between in game characters 2 Answers