コード例 #1
0
    //public makeGhosts mg;

    // Start is called before the first frame update
    void Start()
    {
        points = new List <VerletPoint>();
        lr     = GetComponent <LineRenderer>();

        establishConstraints();

        pn       = GameObject.Find("floor").GetComponent <PerlinNoise>();
        boundBox = new Rectangle(new Vector2(pn.xMin, pn.yMin), new Vector2(pn.xMin, pn.yMax), new Vector2(pn.xMax, pn.yMax), new Vector2(pn.xMax, pn.yMin));

        cannon = GameObject.Find("cannonRectangle").GetComponent <cannon>();

        lr.positionCount = 13;
        dots             = new GameObject[13];
        for (int i = 0; i < 13; i++)
        {
            points.Add(new VerletPoint(this, i, randomPosition.x + coordinates[i, 0], randomPosition.y + coordinates[i, 1], randomPosition.x + firstStep + coordinates[i, 0], randomPosition.y + firstStep + coordinates[i, 1]));

            lr.SetPosition(i, new Vector3(randomPosition.x + firstStep + coordinates[i, 0], randomPosition.y + firstStep + coordinates[i, 1], 0));
            dots[i] = Instantiate(dotPrefab, new Vector3(randomPosition.x + firstStep + coordinates[i, 0], randomPosition.y + firstStep + coordinates[i, 1], 0), Quaternion.identity);
        }



        for (int i = 0; i < 13; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                points[i].distances[j] = Vector2.Distance(new Vector2(points[i].xprev, points[i].yprev), new Vector2(points[j].xprev, points[j].yprev));
            }
        }
    }
コード例 #2
0
ファイル: button.cs プロジェクト: asmccormick/vive-catch
 // Use this for initialization
 void Start()
 {
     myMaterial = gameObject.transform.Find("button").GetComponent<Renderer>().material;
     myMaterial.SetColor ("_Color", Color.green);
     cannonScript = GameObject.Find("Cannon").GetComponent<cannon>();
     Debug.Log ("cannonScript = " + cannonScript);
 }
コード例 #3
0
    void Start()
    {
        screenHeight = camera.orthographicSize;
        screenWidth  = screenHeight * camera.aspect;

        GameObject tip = GameObject.Find("tipOfCannon");

        transform.position = tip.transform.position;

        theta = tip.transform.parent.transform.eulerAngles.z;
        vix   = -launchSpeed *Mathf.Sin(theta *(Mathf.PI / 180)); //sin and cos reversed for Initial x and Initial y velocity because theta = 0 along y axis

        //add negative sign because vix is in left direction (-x direction)
        viy = launchSpeed * Mathf.Cos(theta * (Mathf.PI / 180));

        x = transform.position.x;
        y = transform.position.y;

        cloud = GameObject.Find("cloud").GetComponent <cloud>();

        cannon = GameObject.Find("cannonRectangle").GetComponent <cannon>();
    }