Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            artbb.AddRelativeTorque(Tvec);
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            artbb.AddTorque(Tvec);
        }
    }
    // Update is called once per frame
    void FixedUpdate()
    {
        if (targetBody == null)
        {
            return;
        }

        if (positionToForce.Equals(Vector3.zero))
        {
            targetBody.AddForce(force);
        }
        else
        {
            targetBody.AddForceAtPosition(force, positionToForce);
        }

        targetBody.AddRelativeForce(relativeForce);
        targetBody.AddTorque(torque);
        targetBody.AddRelativeTorque(relativeTorque);

        for (var index = 0; index < targetBody.jointForce.dofCount; index++)
        {
            jointForce[index] = targetBody.jointForce[index];
        }
        for (var index = 0; index < targetBody.jointAcceleration.dofCount; index++)
        {
            jointAcceleration[index] = targetBody.jointAcceleration[index];
        }
        for (var index = 0; index < targetBody.jointVelocity.dofCount; index++)
        {
            jointVelocity[index] = targetBody.jointVelocity[index];
        }
        for (var index = 0; index < targetBody.jointPosition.dofCount; index++)
        {
            jointPosition[index] = targetBody.jointPosition[index];
        }
    }