Ejemplo n.º 1
0
 void MoveToTarget()
 {
     if (RecreateOwnMathematics.Distance(new RecreateCoordinates(this.transform.position), new RecreateCoordinates(fuelManager.transform.position)) > stoppingDistance)
     {
         transform.position += direction * speed * Time.deltaTime;
     }
 }
    //Craete my own translate
    static public RecreateCoordinates Translate(RecreateCoordinates position, RecreateCoordinates facing, RecreateCoordinates vector)
    {
        if (RecreateOwnMathematics.Distance(new RecreateCoordinates(0, 0, 0), vector) <= 0)
        {
            return(position);
        }

        float angle      = RecreateOwnMathematics.Angle(vector, facing);
        float worldAngle = RecreateOwnMathematics.Angle(vector, new RecreateCoordinates(0, 1, 0));
        bool  clockwise  = false;

        if (RecreateOwnMathematics.CrossProduct(vector, facing).z < 0)
        {
            clockwise = true;
        }

        vector = RecreateOwnMathematics.Rotate(vector, angle + worldAngle, clockwise);

        float xValue = position.x + vector.x;
        float yValue = position.y + vector.y;
        float zValue = position.z + vector.z;

        return(new RecreateCoordinates(xValue, yValue, zValue));
    }