// Update is called once per frame public void Update(float dt) { if (input.GetKey(ControllerAction.R1) || (birdControl.DEBUG_ENABLE_KEYBOARD && Input.GetKey(KeyCode.S))) { tail_held += dt * 7f; tail_held = Mathf.Min(tail_held, 1f); } else { tail_held -= dt * 3f; tail_held = Mathf.Max(tail_held, 0f); } tail_1.bone.localRotation = tail_1.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(0, 30f, tail_held), Vector3.right); tail_2.bone.localRotation = tail_2.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(0, 50f, tail_held), Vector3.right); tail_3.bone.localRotation = tail_3.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(0, 20f, tail_held), Vector3.right); }
public void Update(float dt) { Vector2 stick = input.GetLeftStick(); stick.x = stick.x * -1f; if (birdControl.DEBUG_ENABLE_KEYBOARD) { const float MOV_AMOUNT = 0.12f; if (Input.GetKey(KeyCode.I)) { _keyboardInput.y -= MOV_AMOUNT; } if (Input.GetKey(KeyCode.K)) { _keyboardInput.y += MOV_AMOUNT; } _keyboardInput.y = Mathf.Clamp(_keyboardInput.y, -1f, 1f); if (Input.GetKey(KeyCode.J)) { _keyboardInput.x += MOV_AMOUNT; } if (Input.GetKey(KeyCode.L)) { _keyboardInput.x -= MOV_AMOUNT; } _keyboardInput.x = Mathf.Clamp(_keyboardInput.x, -1f, 1f); stick = _keyboardInput; _keyboardInput.y *= 0.9f; _keyboardInput.x *= 0.9f; } float beakMod = 1f + 0.45f * beak_held; neck.bone.localPosition = neck.initialLocalPosition + new Vector3(stick.x * NECK_POS_MOD * beakMod, stick.y * NECK_POS_MOD * beakMod); head.bone.localPosition = head.initialLocalPosition + new Vector3(stick.x * HEAD_POS_MOD * beakMod, stick.y * HEAD_POS_MOD * beakMod); /*if (input.GetKey(ControllerAction.R3)) * { * r3_held += dt*10f; * r3_held = Mathf.Min(r3_held, 1f); * } * else * { * r3_held -= dt*5f; * r3_held = Mathf.Max(r3_held, 0f); * * }*/ r3_held = 1f; var normalized = -stick.normalized; head.bone.localRotation = head.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(0, 30f * r3_held, stick.magnitude), new Vector2(normalized.y, normalized.x)); neck.bone.localRotation = neck.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(0, 5f * r3_held, stick.magnitude), new Vector2(normalized.y, normalized.x)); if (input.GetKey(ControllerAction.L1) || input.GetKey(ControllerAction.A) || (birdControl.DEBUG_ENABLE_KEYBOARD && Input.GetKey(KeyCode.W))) { beak_held += dt * 10f; beak_held = Mathf.Min(beak_held, 1f); } else { beak_held -= dt * 15f; beak_held = Mathf.Max(beak_held, 0f); } beack.bone.localRotation = beack.initialLocalRotation * Quaternion.AngleAxis(-35f * beak_held, Vector3.right); }