|
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 ?
(comments are locked)
|
|
//put this code in a java script and attach it to ur main camera "Assets/WeaponScripts/CreerWaypoints.js(2,16): BCE0005: Unknown identifier: 'Waypoint'." my console display this message.
Jun 22 '10 at 03:44 PM
etxtra
Assets/WeaponScripts/CreerWaypoints.js(2,16): BCE0005: Unknown identifier: 'Waypoint'. -where 'CreerWaypoint.js' is my script (it means create waypoint in french)
Jun 22 '10 at 03:47 PM
etxtra
lol? u forgot to add this; "var Waypoint : Transform;"
Jun 22 '10 at 04:04 PM
AnaRhisT
dont use capitals in variables. Unity tends to confude those with functions or classes!
Apr 04 '11 at 10:01 PM
Kroltan
(comments are locked)
|
|
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: "Waypoint" here should point to a variable. add "var Waypoint : GameObject" to the top of the script then drag your prefab onto the script in the Inspector
Jun 22 '10 at 03:51 PM
Novodantis 1
Your solution is exactly like mine, he didn't ask for a timer or something, just an instantiation.
Jun 22 '10 at 04:16 PM
AnaRhisT
Sorry, I meant to be clearer, that's what I meant by "modify the script". I would have added it as a comment but the code got too unwieldly. To me, waypointing pretty much implies more than one node, but I guess that might be done with different objects.
Jun 22 '10 at 04:54 PM
Novodantis 1
(comments are locked)
|
