public void FillInputPackage(InputPkg toFill) { toFill.deltaMouse.x = Input.GetAxis("Mouse X"); toFill.deltaMouse.y = Input.GetAxis("Mouse Y"); toFill.mousePosToRay = toFill.MousePosToRay(Input.mousePosition); if (PlayerManager.Instance.player) { toFill.aimingDirection = (Camera.main.ScreenToWorldPoint(Input.mousePosition) - PlayerManager.Instance.player.transform.position).normalized; } //Debug.Log(string.Format("AimDir:{0},WP:{1},MP:{2}", toFill.aimingDirection.normalized, Camera.main.ScreenToWorldPoint(Input.mousePosition), Input.mousePosition)); toFill.leftMouseButtonPressed = Input.GetMouseButtonDown(0); toFill.leftMouseButtonReleased = Input.GetMouseButtonUp(0); toFill.leftMouseButtonHeld = Input.GetMouseButton(0); toFill.rightMouseButtonPressed = Input.GetMouseButtonDown(1); toFill.middleMouseButtonPressed = Input.GetMouseButtonDown(2); toFill.anyKeyPressed = Input.anyKeyDown; toFill.inventoryPressed = Input.GetButtonDown("Inventory"); toFill.interactPressed = Input.GetButtonDown("Interaction"); toFill.dirPressed.x = Input.GetAxis("Horizontal"); toFill.dirPressed.y = Input.GetAxis("Vertical"); toFill.dirPressed.Normalize(); toFill.jumpPressed = Input.GetButtonDown("Jump"); toFill.switchWeaponPressed = Input.GetButtonDown("Switch Weapon"); }
private void SetInputPkg(InputPkg ip) { ip.throttleAmount = Input.GetAxis("Throttle"); ip.dirPressed = new Vector2(Input.GetAxis("Horizontal") * (invertedYAxis ? -1 : 1), Input.GetAxis("Vertical")); for (int i = 0; i < PlayerController.ABILITY_COUNT_MAX; i++) { ip.abilityKeyPress[i] = GetInputPressType("Ability" + i); } }
void UpdateGunMovement(InputPkg ip) { Vector3 mousePos = Input.mousePosition; // Figure out most position relative to center of screen. // (0, 0) is center, (-1, -1) is bottom left, (1, 1) is top right. ip.gunPitch = (mousePos.y - (Screen.height * 0.5f)) / (Screen.height * 0.5f); ip.gunYaw = (mousePos.x - (Screen.width * 0.5f)) / (Screen.width * 0.5f); // Make sure the values don't exceed limits. ip.gunPitch = -Mathf.Clamp(ip.gunPitch, -1.0f, 1.0f); ip.gunYaw = Mathf.Clamp(ip.gunYaw, -1.0f, 1.0f); }
void UpdateKeyboardThrottle(KeyCode increaseKey, InputPkg ip) { if (Input.GetKey(increaseKey)) { ip.throttle += 50f; } else { ip.throttle -= 10f; } ip.throttle = Mathf.Clamp(ip.throttle, 0.0f, 500); }
public InputPkg GetInputs() { InputPkg inputPkg = new InputPkg(); inputPkg.currentMousePos = Input.mousePosition; float x = Input.GetAxis("Horizontal"); // get left right for the camera to move float z = Input.GetAxis("Vertical"); // get up down for the camera to move inputPkg.cameraDirectionPressed = new Vector3(x, 0, z); inputPkg.objectSelected = getOnClickMousePosWithRayCast(); return(inputPkg); }
private InputPkg ReadPkg() { var buf = new byte[0x10]; var pkg = new InputPkg(); serverStream.Read(buf, 0, 0x10); pkg.HeldKeys = BitConverter.ToUInt64(buf, 0); pkg.LJoyX = BitConverter.ToInt16(buf, 8); pkg.LJoyY = BitConverter.ToInt16(buf, 10); pkg.RJoyX = BitConverter.ToInt16(buf, 12); pkg.RJoyY = BitConverter.ToInt16(buf, 14); return(pkg); }
public InputPkg GetKeysPressed() { InputPkg toRet = new InputPkg(); float x = Input.GetAxis("Horizontal"); //récupération du déplacement Horizontal float y = Input.GetAxis("Vertical"); //récupération du déplacement Vertical bool spacePressed = Input.GetAxis("Jump") > 0; //Appuie sur la bar d'espace ? bool runButtonPressed = Input.GetAxis("Fire3") > 0; //Appuie sur la touche shift gauche ? //remplissage du package toRet.directionPressed = new Vector2(x, y); toRet.spaceBarPressed = spacePressed; toRet.runButtonPressed = runButtonPressed; return(toRet); }
public static InputPkg GetKeysInput() { //Create package InputPkg toRet = new InputPkg(); toRet.A = Input.GetKey(KeyCode.A); toRet.S = Input.GetKey(KeyCode.S); toRet.D = Input.GetKey(KeyCode.D); toRet.W = Input.GetKey(KeyCode.W); toRet.F = Input.GetKeyDown(KeyCode.F); toRet.tool1Pressed = Input.GetKeyDown(KeyCode.Alpha1); toRet.tool2Pressed = Input.GetKeyDown(KeyCode.Alpha2); toRet.tool3Pressed = Input.GetKeyDown(KeyCode.Alpha3); toRet.tool4Pressed = Input.GetKeyDown(KeyCode.Alpha4); return(toRet); }
private void SetInputPkg(InputPkg ip) { #if UNITY_ANDROID //UpdateGyroInput(ip); #else //ship ip.yaw = Input.GetAxis("Horizontal"); ip.pitch = Input.GetAxis("Vertical"); ip.roll = -Input.GetAxis("Horizontal") * 0.5f; UpdateKeyboardThrottle(KeyCode.LeftShift, ip); ip.hyperDrive = Input.GetKey(KeyCode.Space); // gun UpdateGunMovement(ip); ip.fire = Input.GetMouseButton(0); #endif }
void UpdateGyroInput(InputPkg ip) { Vector3 deviceEulers = DeviceRotation.Get().eulerAngles; Vector3 deltaEulers = previousGyroEuler - deviceEulers; previousGyroEuler = deviceEulers; //if (deltaEulers.x > gyroXsensitivity) ip.gunPitch = deltaEulers.x; /*else * ip.gunPitch = 0;*/ //if (deltaEulers.y > gyroYsensitivity) ip.gunYaw = deltaEulers.y; /*else * ip.gunYaw = 0;*/ }
public static InputPkg ReadPkg(UsbCtx ctx) { if (!ctx.IsSet) { SetCtx(ctx); } var buf = new byte[0x10]; var pkg = new InputPkg(); ctx.Read.Read(buf, 1000, out int len); pkg.HeldKeys = BitConverter.ToUInt64(buf, 0); pkg.LJoyX = BitConverter.ToInt16(buf, 8); pkg.LJoyY = BitConverter.ToInt16(buf, 10); pkg.RJoyX = BitConverter.ToInt16(buf, 12); pkg.RJoyY = BitConverter.ToInt16(buf, 14); return(pkg); }
private void FillInputPkg(InputPkg toFill) { if (!toFill.jumpFirstPressed && Input.GetAxis("Horizontal") > 0) { toFill.jumpFirstPressed = true; } else { toFill.jumpFirstPressed = false; } Vector2 dirPressed = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); if (dirPressed != Vector2.zero) { toFill.lastNonZeroInput = dirPressed; } toFill.moveInput = dirPressed; toFill.useHosePressed = Input.GetButton("Fire"); }
private void SetInputPkg(InputPkg inputPkg) { inputPkg.shootPressed = Input.GetKeyDown(KeyCode.Space); inputPkg.shootHeld = Input.GetKey(KeyCode.Space); inputPkg.dirPressed = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); }
public void Initialize() { fixedUpdateInputPkg = new InputPkg(); updateInputPkg = new InputPkg(); }
public InputPkg inputPressed; //Every update we fill this // // // public void Initialize() { fixedInputPressed = new InputPkg(); inputPressed = new InputPkg(); }
private void SetInputPkg(InputPkg ip) { ip.fire = Input.GetButton("Jump"); ip.dirPressed = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).normalized; }