Exemple #1
0
    void TranslateMovement()
    {
        float translation = Input.GetAxis("Vertical") * speed;
        float rotation    = Input.GetAxis("Horizontal") * rotationSpeed;

        translation *= Time.deltaTime;
        rotation    *= Time.deltaTime;

        transform.position = RecreateOwnMathematics.Translate(new RecreateCoordinates(transform.position), new RecreateCoordinates(transform.up), new RecreateCoordinates(0, translation, 0)).ConvertToVector();

        transform.up = RecreateOwnMathematics.Rotate(new RecreateCoordinates(this.transform.up), rotation * 180.0f / Mathf.PI, true).ConvertToVector();
    }
Exemple #2
0
    void Movement()
    {
        float translation = Input.GetAxis("Vertical") * speed;
        float rotation    = Input.GetAxis("Horizontal") * rotationSpeed;

        translation *= Time.deltaTime;
        rotation    *= Time.deltaTime;

        //transform.Translate(new Vector3(0, translation, 0));
        //transform.Rotate(new Vector3(0,0,-rotation));

        transform.position = RecreateOwnMathematics.Translate(new RecreateCoordinates(transform.position), new RecreateCoordinates(transform.up), new RecreateCoordinates(0, translation, 0)).ConvertToVector();

        //My Own Movement drived my own mathematics normal,dot product, angle , rotate and cross product
        transform.up = RecreateOwnMathematics.Rotate(new RecreateCoordinates(transform.up), rotation * Mathf.PI / 180, true).ConvertToVector();
    }
    //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));
    }