Hi everyone. my question is: how to instantiate a prefab during runtime, with a javascript ?:
-prefab name: Waypoint
-the script will not be attached to the prefab but it will be attached to the camera: I want the camera to instantiate the prefab 'Waypoint' to the coordinate of the camera and with no particular rotation.
-if the above is not possible, then I would like to attach the script to prefab 'Waypoint' itself and instantiate the 'Waypoint' prefab to the coordinates of the camera: how can I do ?
If you want the script to seed them repeatedly over time (not many uses in just creating one, before the game even reaches the first frame) then you can modify the script quite easily, as such:
var seedRate = 5.0; // creates 1 waypoint per 5 seconds
private var timer = 0.0;
function Update() {
if (timer > seedRate) {
Instantiate(Waypoint,transform.position,Quaternion.identity);
timer = 0;
} else {
timer += Time.deltaTime;
}
}