예제 #1
0
 // Update is called once per frame
 void Update()
 {
     windSpeed  = wind.getWind();
     Velocity.x = windSpeed;
     Velocity.y = 0;
     gameObject.transform.Translate(Velocity * Time.deltaTime);
 }
예제 #2
0
    // verlet updates
    void Move()
    {
        if (points[0].position.y > 6f)
        {
            windSpeed = wind.getWind() * 0.2f * Time.deltaTime / 1.25f;                            //get wind
        }
        else
        {
            windSpeed = 0;
        }

        for (int i = 0; i < 19; i++)
        {
            if (i == 8)
            {
                i = 18;
            }

            //apply initial velocity on first movement, inertia afterwards
            if (!firstMove)
            {
                velX[i] = points[i].position.x - previousPos[i].x + Velocity.x;
                velY[i] = points[i].position.y - previousPos[i].y + Velocity.y;
            }
            else
            {
                velX[i] = direction * initialVelocity * Time.deltaTime / 20;
                if (inTheAir)
                {
                    // do nothing
                }
                else
                {
                    velY[i] = 0;
                }
            }

            //verlet formulas
            currentPos[i].x = points[i].position.x + velX[i] + windSpeed;
            if (inTheAir)
            {
                velY[i]         = velY[i] + gravity * Time.deltaTime * 5;
                currentPos[i].y = points[i].position.y + velY[i];
            }

            previousPos[i].x = points[i].position.x;
            previousPos[i].y = points[i].position.y;


            points[i].position = new Vector3(currentPos[i].x, currentPos[i].y, 0);
        }
        firstMove = false;
    }
예제 #3
0
    void Move()
    {
        windSpeed = wind.getWind() * 0.2f;
        // Debug.Log(Time.deltaTime);
        if (Position.y > 6.0 && !bounce)
        {
            Velocity.x = Velocity.x + windSpeed;
        }

        Velocity.y = Velocity.y + gravity * Time.deltaTime * 50;
        gameObject.transform.Translate(Velocity * Time.deltaTime);
        Position = gameObject.transform.position;
    }