Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("q"))
        {
            ms = transform.GetComponent <SampleMouseSlicer>();
            if (ms.enabled)
            {
                ms.enabled = false;
                knifePlane.GetComponent <MeshRenderer>().enabled = false;
            }
            else
            {
                ms.enabled = true;
                knifePlane.GetComponent <MeshRenderer>().enabled = true;
            }
        }

        if (ms.enabled)
        {
            Vector3    mPos   = Input.mousePosition;
            Ray        camRay = Camera.main.ScreenPointToRay(mPos);
            RaycastHit hit;
            if (Physics.Raycast(camRay, out hit))
            {
                knifePlane.transform.position = new Vector3(hit.point.x, hit.point.y + 2.5f, hit.point.z);
            }
            if (Input.GetMouseButton(0))
            {
                //particle
                //transform.Find("KnifePlane/KnifeParticleBig").GetComponent<ParticleSystem>().Simulate(0,false,true);

                transform.Find("KnifePlane/KnifeParticleBig").GetComponent <ParticleSystem>().Play();
            }
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     ms = transform.GetComponent <SampleMouseSlicer>();
 }