private void FixedUpdate() { if (hero.velocity.x < heroMaxSpeed) { float h = CnInputManager.GetAxis("Horizontal"); hero.AddForce(Vector2.right * heroSpeed * heroSpeedFactor * h, ForceMode2D.Force); } }
void ControlWithVirtualPad() { deltaVec = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); base.Movable(deltaVec); base.Shootable(CnInputManager.GetButton("Push"), CnInputManager.GetButton("Pull"), CnInputManager.GetButtonUp("Pull")); }
private void FixedUpdate() { float h = CnInputManager.GetAxis("Horizontal"); // Pass all parameters to the character control script. m_Character.Move(h, m_Jump); m_Jump = false; }
private void Update() { if (!m_Jump) { // Read the jump input in Update so button presses aren't missed. m_Jump = CnInputManager.GetButtonDown("Jump"); } }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonDown("Pause")) { Time.timeScale = 1.0f; gameObject.SetActive(false); } }
/// <summary> /// Мтод выполняет перемещение: /// </summary> void playerMove() { //если нажата стрелка if (Input.GetAxis("Vertical") != 0 & runon == false) { //this.transform.position += transform.forward * speed * Input.GetAxis ("Vertical"); Vector3 direction = transform.forward * speed * Input.GetAxis("Vertical"); this.myRigidbody.AddForce(direction * 1000); AnimatorStateInfo stateInfo = HorseAnimator.GetCurrentAnimatorStateInfo(0); if (!stateInfo.IsName(walk)) { HorseAnimator.Play(walk, 0); } //currentEnergy -= walkGandicap * Time.deltaTime; } //если нажат джойстик if (CnInputManager.GetAxis("Vertical") != 0 & Input.GetAxis("Vertical") == 0 & runon == false) { //this.transform.position += transform.forward * speed * CnInputManager.GetAxis("Vertical"); Vector3 direction = transform.forward * speed * CnInputManager.GetAxis("Vertical"); this.myRigidbody.AddForce(direction * 1000); AnimatorStateInfo stateInfo = HorseAnimator.GetCurrentAnimatorStateInfo(0); if (!stateInfo.IsName(walk)) { HorseAnimator.Play(walk, 0); } //currentEnergy -= walkGandicap * Time.deltaTime; } //если нажата стрелка и шифт if ((Input.GetKey(KeyCode.LeftShift) & (Input.GetAxis("Vertical") != 0 & !buttonDown & !asRun) || (CnInputManager.GetAxis("Vertical") != 0) & buttonDown & runon == true & !asRun)) { //this.transform.position += transform.forward * runSpeed * Input.GetAxis ("Vertical"); Vector3 direction = Vector3.zero; if (Input.GetAxis("Vertical") != 0) { direction = transform.forward * runSpeed * Input.GetAxis("Vertical"); } if (CnInputManager.GetAxis("Vertical") != 0) { direction = transform.forward * runSpeed * CnInputManager.GetAxis("Vertical"); } myRigidbody.AddForce(direction * 800); AnimatorStateInfo stateInfo = HorseAnimator.GetCurrentAnimatorStateInfo(0); if (!stateInfo.IsName(run)) { HorseAnimator.Play(run, 0); } currentEnergy -= runGandicap * Time.deltaTime; } if (Input.GetAxis("Vertical") == 0 & CnInputManager.GetAxis("Vertical") == 0) { HorseAnimator.Play(idle, 0); } }
void Update() { //Запускаем таймер: if (level_time > 0) { level_time -= Time.deltaTime; level_time_info.text = level_time.ToString(); } else { // Тут выпускаем гончих: for (int i = 0; i < Map.Instance.extra_enemy_in_map_count; i++) { Map.Instance.createEnemyToMap(1); } // Пусть и не из оригинала но ставим таймер снова level_time = Map.Instance.level_time; } // Выполняем любой код только если игрок жив switch (state) { case playerState.live: // Остальные методы: rotate(); move(nextPosition); if (islocalPlayer) { Schoot(); // Обрабатываем движение вперед: if ((Input.GetAxis("Vertical") > 0) & (!IsMoving) || (CnInputManager.GetButtonUp("moveButton") && (!IsMoving))) { IsMoving = true; nextPosition = getNextPosition(aStar.mapPointDictionary); } } break; case playerState.destroy: // Проигрываем последнюю анимацию: destroy(); state = playerState.off; break; case playerState.off: StartCoroutine(looses()); break; case playerState.win: StartCoroutine(wines()); // Играем победную анимацию: winn(); break; } }
protected virtual void Update() { button?.SetActive(currentTime <= 0f); currentTime -= Time.deltaTime; if (CnInputManager.GetButtonDown("Ultra") && currentTime <= 0f) { Ult(); } }
void Update() { Vector2 axis = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); transform.Translate(axis * speed * Time.deltaTime, Space.World); transform.Translate(speedOffset * Time.deltaTime, Space.World); //Debug.Log(axis); }
private void Update() { // 왼쪽 키를 누르면 //if (Input.GetKeyDown(KeyCode.LeftControl)) if (CnInputManager.GetButtonDown("LaserFire")) { Shot(); // 발포 } }
void Update() { if (Input.GetMouseButton(0)) { Vector3 TouchMagnitude = new Vector3(CnInputManager.GetAxis(Axis.Axis_X), 0, CnInputManager.GetAxis(Axis.Axis_Y)); Vector3 TouchPos = transform.position + TouchMagnitude.normalized; TouchDir = TouchPos - transform.position; } }
private void Update() { if (isOnGround && CnInputManager.GetButtonDown("Jump")) { rigidBody.AddForce(new Vector2(0, jumpForce)); playerAnim.SetBool("Ground", false); playerAudio.PlayOneShot(jumpAudioClip); } }
void Update() { if (CnInputManager.GetButton("Jump") && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(shot, shotSpawn.position, shotSpawn.rotation); audioSource.Play(); } }
private void RotateCamera() { float xRot = CnInputManager.GetAxis("CameraHorizontal") * RotationSpeedX; RotationY -= CnInputManager.GetAxis("CameraVertical") * RotationSpeedY; RotationY = Mathf.Clamp(RotationY, MinimumY, MaximumY); _transform.localRotation *= Quaternion.Euler(0f, -xRot, 0f); _mainCameraTransform.localEulerAngles = new Vector3(-RotationY, _mainCameraTransform.localEulerAngles.y, 0); }
void Update() { if (CnInputManager.GetButton("Jump") && Time.time > nextFire) //if (Input.GetButton("Fire1") && Time.time > nextFire) { nextFire = Time.time + fireRate; Instantiate(shot, shotSpawn.position, shotSpawn.rotation); GetComponent <AudioSource> ().Play(); } }
void Update() { Vector2 movement = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical")); if (movement != Vector2.zero) { Move(movement); } }
private void Run() { // if (isGrounded) State = DarthState.run; Vector3 position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f); transform.position += position * speed * Time.deltaTime; mySpriteRenderer.flipX = position.x < 0.0F; }
//opens the level void OnTriggerStay2D(Collider2D col) { button.SetActive(true); if (CnInputManager.GetButtonDown("Fire1")) { SceneManager.LoadScene(levelName); } }
private void FixedUpdate() { // Pass all parameters to the character control script. bool powerUp = TriggerPowerUpScript.powerUp; float h = CnInputManager.GetAxis("Horizontal"); m_Character.Move(h, m_Jump, powerUp); m_Jump = false; }
void FixedUpdate() { //get the x factor of movement. float xMovement = CnInputManager.GetAxis("Horizontal"); //get the y factor of movement. float yMovement = CnInputManager.GetAxis("Vertical"); Vector2 movement = new Vector2(xMovement, yMovement); }
private SpecialAbility GetAbility() { if (CnInputManager.GetButtonDown(ButtonName)) { return(ChosenAbility); } return(SpecialAbility.Nothing); }
// Update is called once per frame void Update() { if (CnInputManager.GetButtonDown("Cancel")) { //Application.Quit (); Time.timeScale = 0.0f; PausePanel.SetActive(true); } }
void Update() { if (CnInputManager.GetButtonDown("Restart")) { StartCoroutine(go()); animt.SetTrigger("clicked"); AudioSource.PlayClipAtPoint(clickSound, transform.position); } }
void Update() { if (waitForPress && CnInputManager.GetButtonUp("Jump")) { GameManager.instance.AllowPlayerMovement(false); startPrintingText(); waitForPress = false; } }
void Move() { CorectROT(); position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f, 0f); if (position.x > 0) { if (CnInputManager.GetButtonDown("Run")) { speed = run; Debug.Log(run); } else { // transform.rotation = Quaternion.Euler(0, 0, 0); speed = memor_speed; Debug.Log(memor_speed); } gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); RandL = true; gameG.SetBool("RandL", RandL); } else if (position.x < 0) { if (CnInputManager.GetButtonDown("Run")) { speed = run; Debug.Log(run); } else { speed = memor_speed; Debug.Log(memor_speed); } gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); RandL = false; gameG.SetBool("RandL", RandL); } else if (position.x == 0) { gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime); } if (CnInputManager.GetButtonUp("Jump") && isJump) { gameG.ResetTrigger("idle"); gameG.SetTrigger("Jump"); GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, Jump), ForceMode2D.Impulse); } }
void InputMove() { h = Input.GetAxis("Horizontal"); if (h == 0.0f) { //TODO : 터치 컨트롤러 추가 h = CnInputManager.GetAxis("Horizontal"); } if (m_characterCtrl.m_isRightDir && h < 0.0f || (!m_characterCtrl.m_isRightDir && h > 0.0f)) { m_characterCtrl.Flip(); } m_rigidbody.velocity = new Vector2(h * m_moveSpeed * -1, m_rigidbody.velocity.y); //카메라 제어 if (h < 0.0f) //왼쪽 { m_fakeFlip = 0.5f; m_fakePosX = new Vector2(m_fakePlayerPos.position.x + m_fakeFlip, m_fakePlayerPos.position.y); if (m_fakePlayerPos.position.x >= 0.6f) { m_fakeFlip = 0; } else { m_fakePlayerPos.position = Vector3.Lerp(m_fakePlayerPos.position, m_fakePosX, m_fakeSpeed * Time.deltaTime); } } else if (h > 0.0f) //오른쪽 { m_fakeFlip = -0.5f; m_fakePosX = new Vector2(m_fakePlayerPos.position.x + m_fakeFlip, m_fakePlayerPos.position.y); if (m_fakePlayerPos.position.x <= -0.6f) { m_fakeFlip = 0; } else { m_fakePlayerPos.position = Vector3.Lerp(m_fakePlayerPos.position, m_fakePosX, m_fakeSpeed * Time.deltaTime); } } if (h == 0.0f) { m_fakePlayerPos.position = new Vector2(0.0f, m_fakeDefaultPos.position.y); m_fakePosX = new Vector2(0.0f, m_fakePlayerPos.position.y); //m_characterCtrl.gameObject.transform.position = new Vector2(0.0f, 0.0f); } else if (h == 0.0f && m_isSideColCheck == true) { m_characterCtrl.gameObject.transform.position = new Vector2(0.0f, 0.0f);// 충돌로 인한 약간의 좌표가 어긋나는 것을 초기화로 잡아줌 } }
void OnCollisionExit2D(Collision2D col) { if (col.gameObject.tag == "Piso") { JumpFlag = false; if (!CnInputManager.GetButtonDown("Jump")) { } } }
void FixedUpdate() { rigidbody.AddForce(new Vector3(0.0f, 0.0f, forceForward)); Vector3 input = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical")); //if(Android || Mobile) input = new Vector3(CnInputManager.GetAxis("Horizontal"), 0.0f, CnInputManager.GetAxis("Vertical")); //input = input.normalized; rigidbody.AddForce(input * inputMultiplier); }