コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        //data_container = GameObject.FindGameObjectWithTag("DataContainer");
        data_container = Universals.GetDataContainer();

        guy = data_container.GetComponent <DataContainer>().character;

        Cursor.lockState = CursorLockMode.Locked;

        accelerator_x = 0;
        accelerator_y = 0;
        accelerator_z = 0;

        md = new Vector2();

        controller = GetComponent <CharacterController>();

        usage_target      = null;
        current_grounded  = true;
        previous_grounded = true;
        is_walking        = false;

        mouse_look.y = transform.localRotation.x; //data_container.character.rotation_y;//-transform.localRotation.x;
        mouse_look.x = guy.rotation_y;            //character.transform.localRotation.y;

        DoOnStart();
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        counter = 0;

        data_container = GameObject.FindGameObjectWithTag("DataContainer");

        Cursor.lockState = CursorLockMode.Locked;

        guy = data_container.GetComponent <DataContainer>().character;

        data_container.GetComponent <DataContainer>().game.current_scene_name = SceneManager.GetActiveScene().name;

        //Debug.Log(guy.rotation_x + " " + guy.rotation_y + " " + guy.rotation_z);
        if (guy.position_x == 0 && guy.position_y == 0 && guy.position_z == 0)
        {
            character = GameObject.Instantiate(Resources.Load <GameObject>(character_model_name),
                                               new Vector3(start_location_default.x, start_location_default.y, start_location_default.z),
                                               Quaternion.Euler(guy.rotation_x, guy.rotation_y, guy.rotation_z));
        }
        else
        {
            character = GameObject.Instantiate(Resources.Load <GameObject>(character_model_name),
                                               new Vector3(guy.position_x, guy.position_y, guy.position_z),
                                               Quaternion.Euler(guy.rotation_x, guy.rotation_y, guy.rotation_z));
        }

        // The scene's backup camera is deleted, so that the player character's camera can work.
        GameObject.FindGameObjectWithTag("CameraBackup").SetActive(false);

        // The camera is instantiated
        camera = Resources.Load <Camera>("CameraPrefab");

        // The player character has the camera attached to the main body's camera anchor
        Universals.BuildCharacter(character, camera);
    }
コード例 #3
0
    private void AcceleratorScale()
    {
        if ((Mathf.Abs(velocity.x) < Mathf.Abs(velocity_endgoal.x) && Mathf.Sign(velocity.x) == Mathf.Sign(velocity_endgoal.x)) ||
            accelerator_x == 0)
        {
            Universals.LerpBetter(accelerator_x, 1f, acceleration_true * Time.deltaTime);
        }
        else
        {
            Universals.LerpBetter(accelerator_x, 0, acceleration_true * Time.deltaTime);
        }

        if ((Mathf.Abs(velocity.y) < Mathf.Abs(velocity_endgoal.y) && Mathf.Sign(velocity.y) == Mathf.Sign(velocity_endgoal.y)) ||
            accelerator_y == 0)
        {
            Universals.LerpBetter(accelerator_y, 1f, acceleration_true * Time.deltaTime);
        }
        else
        {
            Universals.LerpBetter(accelerator_y, 0, acceleration_true * Time.deltaTime);
        }

        if ((Mathf.Abs(velocity.z) < Mathf.Abs(velocity_endgoal.z) && Mathf.Sign(velocity.z) == Mathf.Sign(velocity_endgoal.z)) ||
            accelerator_z == 0)
        {
            Universals.LerpBetter(accelerator_z, 1f, acceleration_true * Time.deltaTime);
        }
        else
        {
            Universals.LerpBetter(accelerator_z, 0, acceleration_true * Time.deltaTime);
        }
    }
コード例 #4
0
    public static void BuildCharacter(GameObject body, Camera camera)
    {
        GameObject camera_anchor_this = Universals.FindChild(body, "CameraAnchor");

        camera = Instantiate(camera, camera_anchor_this.transform.position, camera_anchor_this.transform.rotation);

        camera.transform.parent = camera_anchor_this.transform;
    }
コード例 #5
0
    public virtual void GetCameraMovement()
    {
        if (!action_detector.item_rotate)
        {
            md.x  = action_detector.mouse_x * (Universals.GetNPCSensitivity() * 50) * Time.deltaTime;
            md.y -= action_detector.mouse_y * (Universals.GetNPCSensitivity() * 50) * Time.deltaTime;

            md.y = Mathf.Clamp(md.y, -90f, 90f);

            camera.transform.localRotation = Quaternion.Euler(md.y, 0, 0);
            transform.Rotate(Vector3.up * md.x);
        }
    }
コード例 #6
0
    private void Walk()
    {
        if (action_detector.move_forward &&
            !action_detector.move_backward)
        {
            velocity_endgoal.z = 1;
        }
        else if (!action_detector.move_forward &&
                 action_detector.move_backward)
        {
            velocity_endgoal.z = -1;
        }
        else
        {
            velocity_endgoal.z = 0;
        }

        if (action_detector.move_right &&
            !action_detector.move_left)
        {
            velocity_endgoal.x = 1;
        }
        else if (!action_detector.move_right &&
                 action_detector.move_left)
        {
            velocity_endgoal.x = -1;
        }
        else
        {
            velocity_endgoal.x = 0;
        }

        if ((action_detector.move_forward && action_detector.move_left) ||
            (action_detector.move_forward && action_detector.move_right) ||
            (action_detector.move_backward && action_detector.move_left) ||
            (action_detector.move_backward && action_detector.move_right))
        {
            velocity_endgoal.z *= Universals.GetAngularSpeed(speed);
            velocity_endgoal.x *= Universals.GetAngularSpeed(speed);
        }
        else
        {
            velocity_endgoal.z *= speed;
            velocity_endgoal.x *= speed;
        }

        //velocity_endgoal.z *= Time.deltaTime;
        //velocity_endgoal.x *= Time.deltaTime;
    }
コード例 #7
0
    private void MovementLerpUnifiedXZ()
    {
        //Debug.Log(velocity_endgoal);

        float ratio;

        if (Mathf.Abs(velocity_endgoal.x - velocity.x)
            > Mathf.Abs(velocity_endgoal.z - velocity.z))
        {
            ratio      = Mathf.Abs(velocity_endgoal.z - velocity.z) / Mathf.Abs(velocity_endgoal.x - velocity.x);
            velocity.x = Universals.LerpBetter(velocity.x, velocity_endgoal.x, acceleration_true * Universals.GetTimeFake());
            velocity.z = Universals.LerpBetter(velocity.z, velocity_endgoal.z, acceleration_true * ratio * Universals.GetTimeFake());
        }
        else
        {
            ratio      = Mathf.Abs(velocity_endgoal.x - velocity.x) / Mathf.Abs(velocity_endgoal.z - velocity.z);
            velocity.z = Universals.LerpBetter(velocity.z, velocity_endgoal.z, acceleration_true * Universals.GetTimeFake());
            velocity.x = Universals.LerpBetter(velocity.x, velocity_endgoal.x, acceleration_true * ratio * Universals.GetTimeFake());
        }
    }
コード例 #8
0
    public override void DoOnUpdate()
    {
        base.DoOnUpdate();

        if (Time.timeScale > 0.1f)
        {
            lean_goal = LeanGoalGenerate();

            lean.z = Universals.LerpBetter(lean.z, lean_goal, lean_speed_scalar * Time.deltaTime);

            LeanSet();

            //MovementLean();

            //ControlLean();

            CycaBlyat();
        }

        RecordPosRotData();
    }
コード例 #9
0
 public static float GetGravityFake()
 {
     return(Physics.gravity.y * Universals.GetTimeFake());
 }
コード例 #10
0
 private void MovementLerpY()
 {
     velocity.y = Universals.LerpBetter(velocity.y, velocity_endgoal.y, acceleration * Time.deltaTime);
 }