- Home /
how do you add a script remotely?
How do you add a script to an object from another script? I have a script that detects a collision, adds a prefab in its location, deletes the object it collided with, deletes its own mesh renderer, but I can't figure out how to add a script to the prefab I just made.
The reason for the script is that I need two half papers to come together when they touch. After that the player needs to click on the whole paper to go to the next level.
Here is the script (don't comment on he correct language because I don't have access to the file right now)
var the prefab : gameObject(//wholepaper);
function OnCollisionEnter (mycollision : Collision) { if(mycolision.gameObject.name == "PaperB"){ destroy(gameObject.Find("PaperB); destroy(getcomponent(meshrenderer)); var instance : GameObject = Instantiate(thePrefab, transform.position, transform.rotation); *(Add (nextlevel)script to wholepaper object); } }
If anyone could help, it would be much appreciated.
*the part of the code I need help with.
Your answer
![](https://koobas.hobune.stream/wayback/20220613101304im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to make a selection system? 1 Answer
Why won't it run 1 Answer