- Home /
 
How to limit the swipe in a certain area.
I using Line Renderer and using it to destroy an object.
Now i would like to limit the swipe in an area, for example, player is at down left, starting from the player in a 90 degree to top right. player only can swipe the screen in this area.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class LineFollow : MonoBehaviour {
 
     int vertexcount;
     public bool mousedown = false;
     private LineRenderer line;
 
     // Use this for initialization
     void Start () {
         line = GetComponent<LineRenderer> ();
         //line.SetPosition(1,  
     }
     
     // Update is called once per frame
     void Update () {
         if (Input.GetMouseButtonDown (0)) {
             mousedown = true;
         }
 
         if (mousedown) {
             line.positionCount = vertexcount + 1;
             //line.SetVertexCount (vertexcount + 1);
             Vector3 mousepos = Camera.main.ScreenToWorldPoint(new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 15f));
             line.SetPosition (vertexcount, mousepos);
             vertexcount++;
             BoxCollider collider = gameObject.AddComponent<BoxCollider> ();
             collider.transform.position = line.transform.position;
             collider.size = new Vector3 (.3f, .3f);
         }
         if (Input.GetMouseButtonUp (0)) {
             vertexcount = 0;
             line.positionCount = 0;
             //line.SetVertexCount (0);
             mousedown = false;
             DestroyCollider ();
         }
     }
 
     private void DestroyCollider()
     {
         BoxCollider[] box = GameObject.FindObjectsOfType<BoxCollider> ();
         foreach (BoxCollider _box in box) {
             Destroy (_box);
         }
     }
 
     void OnTriggerEnter(Collider col)
     {
         Debug.Log ("gg");
         if (col.tag == "mons") {
             Destroy (col.gameObject);
         }
     }
 }
 
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Change controls from mouse to touch C# 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Change the rotation of Z through swipe 0 Answers
How to create a Touch Pad to control camera rotation 0 Answers