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); }
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); } }