示例#1
0
    public void FallingUpdate(CharacterMotor self)
    {
        SphereUtility.Accelerate(ref self.phi, ref self.theta, ref self.vertical_velocity, ref self.horizontal_velocity, 0.03f, -self.input.x / 10, Time.fixedDeltaTime);

        self.current_position   = SphereUtility.SphereToCartesian(new Vector2(self.phi, self.theta));
        self.transform.rotation = Quaternion.LookRotation(self.current_position, self.North);
    }
示例#2
0
    public void Move(Vector2 input)
    {
        if (between_levels) //FEATURE: enable movement (grounded and aerial) in between_levels
        {
            connection.data.Move(Input.GetAxis("Vertical"), this);
        }
        else if (grounded) //FIXME: this entire block if it is JANK //spelling -_-'
        {
            if (input.sqrMagnitude > 1)
            {
                input.Normalize();
            }

            Transform camera_transform = GameObject.Find("MainCamera").transform; //FIXME: JANK

            Vector3 input3D = new Vector3(input.x, input.y, 0f);                  //FIXME: JANK
            if (input3D.sqrMagnitude > 1)
            {
                input3D.Normalize();
            }

            float left_product  = Vector3.Dot(camera_transform.rotation * input3D, left);
            float right_product = Vector3.Dot(camera_transform.rotation * input3D, right);
            float product       = -Mathf.Abs(left_product);
            if (right_product > left_product)
            {
                product = +Mathf.Abs(right_product);
            }
            if (right_product < 0 && left_product < 0)
            {
                product = 0;
            }
            angle += product / height / 64; //FIXME: slight math error here-ish

            current_position = ArcOfSphere.Evaluate(ground.data, radius);

            transform.rotation = Quaternion.LookRotation(current_position, arc.EvaluateNormal(angle, radius));
        }
        else
        {
            SphereUtility.Accelerate(ref phi, ref theta, ref vertical_velocity, ref horizontal_velocity, 0.03f, -input.x / 10, Time.fixedDeltaTime);

            current_position   = SphereUtility.SphereToCartesian(new Vector2(phi, theta));
            transform.rotation = Quaternion.LookRotation(current_position, North);
        }
    }
示例#3
0
    public override void Move(float delta, CharacterMotor motor)
    {
        interpolation_distance += delta * direction * Time.deltaTime;

        float exponent = Mathf.Clamp01(interpolation_distance / 10);

        motor.radius = Mathf.Pow(start_size, 1 - exponent) * Mathf.Pow(end_size, exponent);

        Vector2 phi_theta = new Vector2(motor.radius, 0f);

        motor.current_position = SphereUtility.SphereToCartesian(phi_theta, up, up, forward);

        if (interpolation_distance < 0)
        {
            ExitNexus(motor);
        }
        else if (interpolation_distance > 10f)
        {
            RoomLoader.Instance.UnloadRoom(near_id);
            RoomLoader.Instance.LoadRoom(far_id);
            ExitNexus(motor);
        }
    }
示例#4
0
 protected override Vector3 Center(float radius)
 {
     return(SphereUtility.SphereToCartesian(new Vector2(radius / Mathf.Cos(arc_angle / 2), arc_angle / 2), arc_left, arc_left_normal, path_normal));        //wow, I can't believe it was really cos(angle/2)
 }
示例#5
0
 public override Vector3 EvaluateRight(float angle, float radius) //TODO: optimize
 {
     return(SphereUtility.SphereToCartesian(new Vector2(Mathf.PI / 2 - AngularRadius(radius), angle), arc_left_normal, -arc_left, path_normal));
 }
示例#6
0
 /** return the position of the player based on the circular path
  *
  */
 public override Vector3 Evaluate(float angle, float radius)
 {
     return(SphereUtility.SphereToCartesian(new Vector2(AngularRadius(radius), angle), arc_left, arc_left_normal, path_normal));
 }