コード例 #1
0
    public void DrawTrajectory()
    {
        Polygon2D trajectory = new Polygon2D();
        //trajectory.AddPoint(0, 0);

        Vector2 pos     = spawner.transform.position;
        Vector2 gravity = Physics2D.gravity;
        Vector2 force   = spawner.transform.right * applyForce;

        float timer = 0;

        while (timer < 3)
        {
            float delta = 0.1f;

            trajectory.AddPoint(pos);

            pos   += force * delta;
            force += gravity * delta;

            timer += delta;
        }

        Mesh mesh = Max2DMesh.CreatePolygon(transform, trajectory, -3f, 1f, false);

        Max2DMesh.Draw(mesh, trajectoryMaterial);
    }
コード例 #2
0
    public void GenerateMesh()
    {
        lineWidthSet = lineWidth;

        if (mesh != null)
        {
            DestroyImmediate(mesh);
        }

        mesh = Max2DMesh.CreatePolygon(transform, GetPolygon(), lineOffset, lineWidth, edgeCollider == false);
    }