// Update is called once per frame void Update() { if (!saliste) { vertical = Input.GetAxis("Vertical"); horizontal = Input.GetAxis("Horizontal"); miRigidbody.AddForce(new Vector3(horizontal, 0, vertical) * velocidad); miRigidbody.AddForce(new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"), 0, CrossPlatformInputManager.GetAxis("Vertical")) * velocidad); } if (CrossPlatformInputManager.GetButton("Jump") && Mathf.Abs(miRigidbody.velocity.y) < 0.01f) { miRigidbody.AddForce(Vector3.up * fuerzaSalto, ForceMode.Impulse); } }
private void PollInput() { _joystickPosition.x = CrossPlatformInputManager.VirtualAxisReference("Vertical").GetValue; _joystickPosition.y = CrossPlatformInputManager.VirtualAxisReference("Horizontal").GetValue * -1f; if (CrossPlatformInputManager.GetButtonDown("Fire1") || CrossPlatformInputManager.GetButton("Fire1")) { _isFiring1 = true; } if (CrossPlatformInputManager.GetButtonUp("Fire1")) { _isFiring1 = false; } }
// Update is called once per frame void Update() { if (manager.recording) { Record(); } else { PlayBack(); } if (CrossPlatformInputManager.GetButton("Fire1")) { frameStop = Time.frameCount; } }
private void UpdateInputs() { this.m_Inputs.m_Horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); this.m_Inputs.m_Vertical = CrossPlatformInputManager.GetAxis("Vertical"); this.m_Inputs.m_Jump = CrossPlatformInputManager.GetButton("Jump"); this.m_Inputs.m_Duck = CrossPlatformInputManager.GetButton("Duck"); if (Input.GetKeyDown(KeyCode.LeftShift)) { this.m_Inputs.m_Sprint = !this.m_Inputs.m_Sprint; } Vector2 lookInput = InputHelpers.GetLookInput(this.m_LookSensitivityX, this.m_LookSensitivityY, 150f); this.m_Inputs.m_MouseX = lookInput.x; this.m_Inputs.m_MouseY = lookInput.y; }
void Fall() { if (myRigidBody.velocity.y < 0) { myRigidBody.velocity += Physics2D.gravity * (fallMultiplier - 1) * Time.deltaTime; } else if (myRigidBody.velocity.y > 0 && !CrossPlatformInputManager.GetButton("Jump")) { myRigidBody.velocity += Vector2.up * Physics2D.gravity * (lowJumpMultiplier - 1) * Time.deltaTime; } else if (myRigidBody.velocity.y == 0 && myFeet.IsTouchingLayers(LayerMask.GetMask("Ground"))) { animator.SetBool("Jumping", false); } }
// Update is called once per frame void Update() { // 2 opcje - pierwsza zmienna grounded - bool // Movement(); // v2 jest czystsza i bardziej praktyczna - ale obie dzialaja // CheckGrounded(); //druga opcja to pominiecie boola przez 'return type function' Movement_v2(); // if (Input.GetMouseButtonDown(0) && IsGrounded()) // IsGrounded() == true -- rownoznaczne if ((Input.GetMouseButtonDown(0) || CrossPlatformInputManager.GetButton("A_Button")) && IsGrounded()) { playerAnimation.TriggerAttack(); } }
// Update is called once per frame void Update() { recording = !CrossPlatformInputManager.GetButton("Fire1"); if (Input.GetKeyDown(KeyCode.P)) { if (!paused) { Pause(); } else { Resume(); } } }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButton("Facil")) //Esta condicion hace que cuando se presiona el boton de "Un jugador" se envie al usuario a la seleccion de personaje { SceneManager.LoadScene("Seleccion_Personaje"); //Esta funcion hace que la escena seleccionada se cargue } if (CrossPlatformInputManager.GetButton("Medio")) //Esta condicion hace que cuando se presiona el boton de "Un jugador" se envie al usuario a la seleccion de personaje { SceneManager.LoadScene("Seleccion_Personaje"); //Esta funcion hace que la escena seleccionada se cargue } if (CrossPlatformInputManager.GetButton("Dificil")) //Esta condicion hace que cuando se presiona el boton de "Un jugador" se envie al usuario a la seleccion de personaje { SceneManager.LoadScene("Seleccion_Personaje"); //Esta funcion hace que la escena seleccionada se cargue } }
// Update is called once per frame void Update() { // Steering float h = CrossPlatformInputManager.GetAxis("Horizontal"); transform.Rotate(h * steerForce / 10, 0, 0); // Fly up boost = CrossPlatformInputManager.GetButton("Jump"); if (boost) { rb.AddRelativeForce(0, boostForce, 0); } }
// Update is called once per frame void Update() { //Debug.Log("H" + ": " + CrossPlatformInputManager.GetAxis ("Horizontal")); //Debug.Log("V" + ": " + CrossPlatformInputManager.GetAxis ("Vertical")); if (CrossPlatformInputManager.GetButton("Fire3")) { tryingToGrab = true; } else { tryingToGrab = false; isGrabbing = false; } }
void Update() { if (!_dome.CanShoot) { return; } if (CrossPlatformInputManager.GetButton("Fire1")) { if (Time.time > _lastShot + shotCooldown) { Fire(); } } }
// Update is called once per frame void Update() { if (CrossPlatformInputManager.GetButtonDown("C")) { Debug.Log("C-----GetButtonDown"); } if (CrossPlatformInputManager.GetButton("C")) { Debug.Log("C-----GetButton"); } else if (CrossPlatformInputManager.GetButtonUp("C") || CrossPlatformInputManager.GetButtonUp("B")) { SceneManager.LoadScene("Menu"); } }
private void ChangeFOV() { if (CrossPlatformInputManager.GetButton("Fire2")) { Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, zoomMin, Time.deltaTime * zoomSpeed); mouseLook.XSensitivity = Mathf.Lerp(mouseLook.XSensitivity, mouseSensitivityMin, Time.deltaTime * zoomSpeed); mouseLook.YSensitivity = Mathf.Lerp(mouseLook.YSensitivity, mouseSensitivityMin, Time.deltaTime * zoomSpeed); } else { Camera.main.fieldOfView = Mathf.Lerp(Camera.main.fieldOfView, zoomMax, Time.deltaTime * zoomSpeed); mouseLook.XSensitivity = Mathf.Lerp(mouseLook.XSensitivity, mouseSensitivityMax, Time.deltaTime * zoomSpeed); mouseLook.YSensitivity = Mathf.Lerp(mouseLook.YSensitivity, mouseSensitivityMax, Time.deltaTime * zoomSpeed); } }
void Update() { if (CrossPlatformInputManager.GetButton("Fire1")) { recording = false; } else { recording = true; } if (Input.GetKeyDown(KeyCode.P)) { PauseResume(); } }
// Update is called once per frame void Update() { bool pressed = CrossPlatformInputManager.GetButton("Fire3"); if (pressed && Time.time - rechargeTime > timer) { Projectile newFireball = Instantiate(projectile, source.transform.position, Quaternion.identity).GetComponent <Projectile>(); newFireball.CreateProjectile((source.transform.position + Camera.main.transform.forward), projectileSpeed, "PlayerParts"); timer = Time.time; } var emit = fire.GetComponent <ParticleSystem>().emission; emit.enabled = Time.time - rechargeTime > timer; }
void Update() { if (CrossPlatformInputManager.GetButtonDown("Fire1")) { Shot(); } if (CrossPlatformInputManager.GetButton("Fire1")) { ChargeShot(); } if (CrossPlatformInputManager.GetButtonUp("Fire1")) { ReleaseShot(); } }
private void FixedUpdate() { // Read input for the pitch, yaw, roll and throttle of the aeroplane. float roll = CrossPlatformInputManager.GetAxis("Horizontal"); float pitch = CrossPlatformInputManager.GetAxis("Pitch"); m_AirBrakes = CrossPlatformInputManager.GetButton("Fire1"); m_Yaw = CrossPlatformInputManager.GetAxis("Yaw"); m_Throttle = CrossPlatformInputManager.GetAxis("Vertical"); #if MOBILE_INPUT AdjustInputForMobileControls(ref roll, ref pitch, ref m_Throttle); #endif // Pass the input to the aeroplane m_Aeroplane.Move(roll, pitch, m_Yaw, m_Throttle, m_AirBrakes); }
void Update() { if (CrossPlatformInputManager.GetButton("Submit") || Input.anyKeyDown) { if (_sceneName != null) { SceneManager.LoadScene(_sceneName); return; } else { SceneManager.LoadScene(1); } } }
private void FixedUpdate() { float h = 0f; if (CrossPlatformInputManager.GetButton("Punsh")) { _attaque.Punsh(); } else { h = CrossPlatformInputManager.GetAxis("Horizontal"); } _character.Move(h, jump); jump = false; }
void Update() { Archive.CurrentArchive.PlayTime += (long)(Time.unscaledDeltaTime * 1000); // 在 scaleTime = 0 之后也能用 , 即便暂停的时候也在计时 interval += Time.deltaTime; // 在 scaleTime = 0 之后就是 0 , 这样在暂停的时候就不会刷时间了 if (interval > 1.0f) { playTime.text = Archive.CurrentArchive.PlayTimeToStr; interval = 0; } healthSlider.value = healthManager.Health; if (CrossPlatformInputManager.GetButton("O")) { itemAndOption.SetActive(true); } }
void Update() { if (((CrossPlatformInputManager.GetButton("SlideButton")) || (Input.GetKey(KeyCode.S)) && boy.isrunning)) { slideCollider.enabled = true; normalCollider.enabled = false; slideCollider.offset = offset; } else { slideCollider.enabled = false; normalCollider.enabled = true; slideCollider.offset = zero; } }
private void FixedUpdate() { input.fireHold = CrossPlatformInputManager.GetButton("Fire"); input.specialHold = CrossPlatformInputManager.GetButton("Special"); input.afterburnerHold = CrossPlatformInputManager.GetButton("Afterburner"); input.horizontal = CrossPlatformInputManager.GetAxis("Horizontal"); input.vertical = CrossPlatformInputManager.GetAxis("Vertical"); if (player) { player.move(input); player.clampToCameraBound(mainCamera); } input.reset(); }
// Update is called once per frame void Update() { recording = !CrossPlatformInputManager.GetButton("Fire1"); if (Input.GetKeyDown(KeyCode.P) && isPaused) { isPaused = false; ResumeGame(); } else if (Input.GetKeyDown(KeyCode.P) && !isPaused) { isPaused = true; PauseGame(); } }
void FixedUpdate() { if (CrossPlatformInputManager.GetButton("Fire1")) { AnimController.SetFloat(FireName, 1f); AnimController.SetFloat(DrawName, 0f); AnimController.SetFloat(IdleName, 0f); AnimController.SetFloat(ReloadName, 0f); AnimController.SetFloat(AimName, 0f); AnimController.SetFloat(MeleeName, 0f); } else if (CrossPlatformInputManager.GetButton("Reload")) { AnimController.SetFloat(FireName, 0f); AnimController.SetFloat(DrawName, 0f); AnimController.SetFloat(IdleName, 0f); AnimController.SetFloat(ReloadName, 1f); AnimController.SetFloat(AimName, 0f); AnimController.SetFloat(MeleeName, 0f); } else if (CrossPlatformInputManager.GetButton("Fire2")) { AnimController.SetFloat(FireName, 0f); AnimController.SetFloat(DrawName, 0f); AnimController.SetFloat(IdleName, 0f); AnimController.SetFloat(ReloadName, 0f); AnimController.SetFloat(AimName, 1f); AnimController.SetFloat(MeleeName, 0f); } else if (CrossPlatformInputManager.GetButton("Melee")) { AnimController.SetFloat(FireName, 0f); AnimController.SetFloat(DrawName, 0f); AnimController.SetFloat(IdleName, 0f); AnimController.SetFloat(ReloadName, 0f); AnimController.SetFloat(AimName, 0f); AnimController.SetFloat(MeleeName, 1f); } else { AnimController.SetFloat(FireName, 0f); AnimController.SetFloat(DrawName, 0f); AnimController.SetFloat(IdleName, 1f); AnimController.SetFloat(ReloadName, 0f); AnimController.SetFloat(AimName, 0f); AnimController.SetFloat(MeleeName, 0f); } }
// Fixed update is called in sync with physics private void FixedUpdate() { // read inputs float h = CrossPlatformInputManager.GetAxis("Horizontal"); float v = CrossPlatformInputManager.GetAxis("Vertical"); bool crouch = CrossPlatformInputManager.GetButton("Crouch"); bool block = CrossPlatformInputManager.GetButton("Block"); bool attackOne = CrossPlatformInputManager.GetButtonDown("AttackOne"); bool attackTwo = CrossPlatformInputManager.GetButtonDown("AttackTwo"); bool run = CrossPlatformInputManager.GetButton("Run"); bool oneEighty = CrossPlatformInputManager.GetButtonDown("OneEighty"); m_Jump = CrossPlatformInputManager.GetButtonDown("Jump"); Vector3 lookAt; // calculate move direction to pass to character // calculate camera relative direction to move: m_CamForward = Vector3.Scale(Vector3.forward, new Vector3(1, 0, 1)).normalized; m_Move = v * m_CamForward + h * Vector3.right; m_Move = Quaternion.Euler(transform.rotation.eulerAngles) * m_Move; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { Vector3 dir = hit.point - ray.origin; Debug.DrawRay(ray.origin, dir, Color.red, 0); //Debug.Log(hit.point); lookAt = hit.point; } else { lookAt = Vector3.zero; } //lookAt = new Vector3(ray.origin.x, transform.position.y, ray.origin.x); //lookAt -= transform.position; #if !MOBILE_INPUT // walk speed multiplier //if (Input.GetKey(KeyCode.LeftShift)) m_Move *= 0.5f; #endif // pass all parameters to the character control script m_Character.Move(m_Move, crouch, m_Jump, block, attackOne, attackTwo, run, oneEighty, lookAt); m_Jump = false; }
void FixedUpdate() { if (GameStateController.fieldView.transitioning) { return; } if (attacking) { timeSinceLastAttack += Time.deltaTime; if (timeSinceLastAttack >= GameStateController.playerController.GetAttackRate() || CrossPlatformInputManager.GetButtonUp("Left") || CrossPlatformInputManager.GetButtonUp("Right")) { ResetAttack(); } else { return; } } if (CrossPlatformInputManager.GetButton("Right")) { if (engaged && transform.localScale.x == 1) { Attack(); } else { MoveRight(); } } else if (CrossPlatformInputManager.GetButton("Left")) { if (!(GameStateController.characterMetaDataController.characterMetaDataModel.currentDistance == 0 && transform.position.x == -5)) { if (engaged && transform.localScale.x == -1) { Attack(); } else { MoveLeft(); } } } }
// Update is called once per frame void Update() { float xPos = joystick.GetComponent <RectTransform>().anchoredPosition.x; float yPos = joystick.GetComponent <RectTransform>().anchoredPosition.y; float xRotation = (float)(Math.Atan2(xPos, yPos) * (180 / 3.1415) * -1); // Debug.Log(xRotation); //Vector3 rotation = new Vector3(0,0 , xRotation); transform.localEulerAngles = new Vector3(0, 0, xRotation); //transform.Rotate(rotation); Vector2 moveVec = new Vector2(CrossPlatformInputManager.GetAxis("Horizontal"), CrossPlatformInputManager.GetAxis("Vertical")) * moveForce; bool isBoosting = CrossPlatformInputManager.GetButton("Dash"); bool keyboardDash = Input.GetButtonDown("KeyboardDashButton"); if (deltaTime1 == 0) { buttonAvailable = true; } if ((isBoosting || keyboardDash) && buttonAvailable) { deltaTime1 += 1; animation.SetTrigger("Dash"); } if (deltaTime1 >= 1 && deltaTime1 <= 20) { deltaTime1++; isDashing = true; buttonAvailable = false; cooldown.fillAmount += .04f; cooldown.fillAmount = 0; } else if (deltaTime1 > 20 && deltaTime1 < 50) { isDashing = false; buttonAvailable = false; deltaTime1++; cooldown.fillAmount += .04f; } if (deltaTime1 == 50) { deltaTime1 = 0; } myBody.velocity = (moveVec * (isDashing ? dashForce : 1)); //myBody.velocity = (moveVec * dashForce); }
void Update() { if (rb.position.y < -12f) { if (dCount == 0) { FindObjectOfType <AudioManager>().Play("Death"); dCount = 1; totalDeathCount++; dd.SavePlayer(); } if (SceneManager.GetActiveScene().name == "Level01" || SceneManager.GetActiveScene().name == "Level12") { rb.transform.position = new Vector2(targetRespawn.transform.position.x + Random.Range(-4f, 4f), 5f); } else { StartCoroutine(RestartLevel()); } } //jump code if (CrossPlatformInputManager.GetButtonDown("Jump") && isGrounded == true) { anim.SetTrigger("takeOff"); rb.velocity = Vector2.up * jumpForce; FindObjectOfType <AudioManager>().Play("Jump"); } if (isGrounded == true) { anim.SetBool("isJumping", false); } else { anim.SetBool("isJumping", true); } //better Jump Code if (rb.velocity.y < 0) { rb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime; } else if (rb.velocity.y > 0 && !CrossPlatformInputManager.GetButton("Jump")) { rb.velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime; } }
/// <summary> /// プレイヤー移動処理 /// </summary> protected virtual void playerMoveUpdate() { m_PlayerMoveVelocity = Vector3.zero; m_PlayerMoveDetection = Vector3.zero; //前進 if (CrossPlatformInputManager.GetButton("PlayerMoveForward")) { m_PlayerMoveDetection.z += 1.0f; } //後退 if (CrossPlatformInputManager.GetButton("PlayerMoveBack")) { m_PlayerMoveDetection.z -= 1.0f; } //左平行移動 if (CrossPlatformInputManager.GetButton("PlayerMoveLeft")) { m_PlayerMoveDetection.x -= 1.0f; } //右平行移動 if (CrossPlatformInputManager.GetButton("PlayerMoveRight")) { m_PlayerMoveDetection.x += 1.0f; } m_PlayerMoveVelocity = this.transform.TransformDirection(m_PlayerMoveDetection); m_PlayerMoveVelocity *= m_PlayerMoveSpeed; //移動スピード //ジャンプ if (!m_JumpButtonPushingFlag && CrossPlatformInputManager.GetButtonDown("PlayerJump")) { if (m_CharacterController.isGrounded) { Debug.Log("JUMP"); m_PlayerMoveVelocity.y += m_PlayerJumpPower; } m_JumpButtonPushingFlag = true; } else if (CrossPlatformInputManager.GetButtonUp("PlayerJump")) { m_JumpButtonPushingFlag = false; } m_PlayerMoveVelocity.y -= m_PlayerGravity; //重力 m_CharacterController.Move(m_PlayerMoveVelocity * Time.deltaTime); }
private void FixedUpdate() { if (!isAccelation) { Mathf.Clamp(_airplane.MaxSpeed -= 1f, 200, 100); if (_airplane.MaxSpeed < 100) { _airplane.MaxSpeed = 100; isAccelation = true; } } #if UNITY_STANDALONE_WIN //Read input for the pitch, yaw, roll and throttle of the aeroplane. float mousePitch = ControlsPrefs.IsMouseEnabled ? CrossPlatformInputManager.GetAxis("Mouse Y") : 0; float mouseRoll = ControlsPrefs.IsMouseEnabled ? CrossPlatformInputManager.GetAxis("Mouse X") : 0; float roll = ControlsPrefs.IsRollEnabled? CrossPlatformInputManager.GetAxis("Roll") + mouseRoll : 0; //Read inputs. They are clamped in AeroplaneController, so can go out of [-1, 1] here. float pitch = (ControlsPrefs.IsInversePitch ? -1f : 1f) * CrossPlatformInputManager.GetAxis("Pitch"); float yaw = CrossPlatformInputManager.GetAxis("Yaw"); #endif #if UNITY_ANDROID rotateClamp = rightRotateClamp != 0 ? rightRotateClamp : leftRotateClamp; float roll = ControlsPrefs.IsRollEnabled ? rotateClamp : 0; yaw = Input.acceleration.x * 1.5f; float pitch; // float pitch = (ControlsPrefs.IsInversePitch ? -1f : 1f) * (Input.acceleration.y*1.5f); if (PlayerPrefs.GetInt("ReviseDirection") == 0) { pitch = (ControlsPrefs.IsInversePitch ? -1f : 1f) * (Input.acceleration.y * 1.5f); //正向控制 } else { pitch = -(ControlsPrefs.IsInversePitch ? -1f : 1f) * (Input.acceleration.y * 1.5f); //反向控制 } #endif bool airBrakes = CrossPlatformInputManager.GetButton("Brakes"); // auto throttle up, or down if braking. float throttle = airBrakes ? -1 : 1; // Pass the input to the aeroplane _airplane.Move(roll, pitch, yaw, throttle, airBrakes); }