예제 #1
0
        private void LateUpdate()
        {
            Vector3 character_position  = main_character.forward;
            Vector3 controller_position = main_controller.forward;
            Vector3 crosshair_up        = Bearing.repeller(controller_position, character_position);

            crosshair_renderer.angle = Vector3.SignedAngle(main_controller.up, crosshair_up, main_controller.forward) * Mathf.Deg2Rad;
            crosshair_renderer.scale = Mathf.Lerp(0, crosshair_size, DebrisNoirsInput.get_axes().magnitude);
        }
예제 #2
0
        private void ghost_update()
        {
            Vector2 input_direction = DebrisNoirsInput.get_axes();

            if (input_direction.sqrMagnitude > 0)
            {
                float target_angle  = Mathf.Atan2(input_direction.y, input_direction.x) - Mathf.PI / 2;
                float current_angle = internal_transform.localEulerAngles.z;
                float delta_angle   = Mathf.Abs(Mathf.DeltaAngle(current_angle, target_angle * Mathf.Rad2Deg));
                float interpolator  = 360 * 3 / delta_angle * Time.deltaTime;
                float new_angle     = Mathf.LerpAngle(current_angle, target_angle * Mathf.Rad2Deg, interpolator);
                internal_transform.localEulerAngles = new Vector3(0, 0, new_angle);
            }
        }
예제 #3
0
        private void Update()
        {
            if (!dead)
            {
                satellite_update();
            }
            else if (dead_time < 0)
            {
                ghost_update();
            }
            else if (dead_time >= 0)
            {
                dead_update();
            }

            if (dead)
            {
                if (dead_time < 0)
                {
                    ghost_renderer.enabled  = true;
                    crosshair_dot.enabled   = false;
                    crosshair_arrow.enabled = true;
                }
                dead_time    -= Time.deltaTime;
                respawn_time += Time.deltaTime / 2;
                if (DebrisNoirsInput.get_axes().magnitude > 0.3f)
                {
                    respawn_time = 0;
                }
                if (dead_time < 0)
                {
                    if (DebrisNoirsInput.get_axes().magnitude > 0.3f)
                    {
                        satellite_renderer.enabled = false;
                        ghost_renderer.enabled     = true;
                    }
                    else
                    {
                        satellite_renderer.enabled = true;
                        ghost_renderer.enabled     = false; // essentially an OnMouseHover() event where the ship looks like it is alive
                    }
                }
                loading_disc.fillAmount = respawn_time;
                if (respawn_time >= 1)
                {
                    respawn();
                }
            }
        }
예제 #4
0
        private void ghost_fixed_update()
        {
            Vector2 input = DebrisNoirsInput.get_axes(); // HACK: double counting inside function call

            // add velocity based on input
            planetaria_rigidbody.relative_velocity += input * Time.deltaTime;
            Vector2 velocity = planetaria_rigidbody.relative_velocity;

            // drag in coincident direction varies from coefficient of 1->~0.8->~0.5
            float   similarity          = Vector2.Dot(velocity.normalized, input);
            float   drag_modifier       = Mathf.Lerp(0.6f, 1.0f, (similarity + 1f) / 2);
            Vector2 coincident_velocity = input != Vector2.zero ? (Vector2)Vector3.Project(velocity, input) : velocity;

            coincident_velocity *= Mathf.Pow(drag_modifier, Time.deltaTime);

            // get perpendicular velocity (unmodified)
            Vector2 perpendicular_velocity = input != Vector2.zero ? Vector3.ProjectOnPlane(velocity, input) : Vector3.zero;

            // apply velocity changes
            planetaria_rigidbody.relative_velocity = coincident_velocity + perpendicular_velocity;

            // apply unusued drag
            //planetaria_rigidbody.relative_velocity *= Mathf.Pow(0.8f, Time.deltaTime * (1f - input_direction.magnitude));
        }