c# - Unity3D-2D: Setting Time.timeScale to 0 for a certain public prefab until positioned? -
so have button in game spawns "tower" @ given location. tower, when spawned, acts , can drag around using drag script.
i wonder how can set time.timescale 0 when first spawn tower (only prefab) untill click again set it's position.
also after click on button want enable dragging script, set position , after click mouse disable dragging script. way can make sure players don't reposition towers damage.
using unityengine; using system.collections; public class spawntower : monobehaviour { public gameobject frozenobject; public transform prefab; public void onclickspawn() { (int = 0; < 1; i++) { instantiate(prefab, new vector3(i * 2.0f, 0, 0), quaternion.identity); } } //this part here on not work! says getcomponent<>() method not valin in given context public void onclick() { if (input.getmousebuttonup(0)) { getcomponent<dragenemy>.enabled = false; } } }
note part doesn't work
and dragging script reason can't referenced disabled.
using unityengine; using system.collections; [requirecomponent(typeof(boxcollider2d))] public class dragenemy : monobehaviour { private vector3 screenpoint; private vector3 offset; void onmousedown() { offset = gameobject.transform.position - camera.main.screentoworldpoint(new vector3(input.mouseposition.x, input.mouseposition.y, screenpoint.z)); } void onmousedrag() { vector3 curscreenpoint = new vector3(input.mouseposition.x, input.mouseposition.y, screenpoint.z); vector3 curposition = camera.main.screentoworldpoint(curscreenpoint) + offset; transform.position = curposition; } }
Comments
Post a Comment