示例#1
0
    PolarCoordiantes CartesianToPolar(Vector3 coordinates)
    {
        // in reference to world
        // x y z transform to local coordinte system of the planet

        coordinates = world.transform.InverseTransformPoint(coordinates);
        //Debug.Log("coordiantes in local pos " + coordinates);

        PolarCoordiantes pc = new PolarCoordiantes();

        pc.radius = coordinates.magnitude;

        Vector3 yxProjection = coordinates;

        yxProjection.x = 0f;
        pc.theta       = Vector3.Angle(Vector3.up, yxProjection);

        //Debug.Log("theta "+ pc.theta);

        Vector3 xzProjection = coordinates;

        xzProjection.y = 0f;
        pc.theta       = Vector3.Angle(Vector3.up, xzProjection);

        //Debug.Log("theta " + pc.theta);

        return(pc);
    }
示例#2
0
    Vector3 PolarToCartesian(PolarCoordiantes pc)
    {
        Vector3 pos = world.transform.position;

        //Vector3 direction = new Vector3()

        return(Vector3.zero);
    }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        cc             = GetComponent <CharacterController>();
        polarTransform = CartesianToPolar(transform.position);
        positionDir    = Quaternion.LookRotation(transform.position);
        rb             = GetComponent <Rigidbody>();
        if (rb)
        {
            rb.useGravity  = false;
            rb.constraints = RigidbodyConstraints.FreezeRotation;
        }


        anim = GetComponent <Animator>();
    }