unity3d - how to destroy instantiate object unity c# -
using unityengine; using system.collections; public class myscript : monobehaviour { public transform platform; public float z = 0.0f; void update () { float c_z=0.0f; instantiate(platform,new vector3(z++,0,0),quaternion.identity); camera.main.transform.translate (0,0,c_z=c_z+0.1f); } }
in above code platform instantiated , have destroy tail of platform when camera move ahead. how?
try:
using unityengine; using system.collections; public class myscript : monobehaviour { public transform platform; public float z = 0.0f; private gameobject _obj; void update () { float c_z=0.0f; _obj = instantiate(platform,new vector3(z++,0,0),quaternion.identity) gameobject; camera.main.transform.translate (0,0,c_z=c_z+0.1f); } }
then call destroy(obj)
whenever ready destroy platform.
Comments
Post a Comment