// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonReturn", EActionEvent.Click)) { SceneManager.LoadScene("MainMenu", LoadSceneMode.Single); } }
// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonSurvey", EActionEvent.Click)) { SceneManager.LoadScene("Survey1", LoadSceneMode.Single); } }
void Update() { #if UNITY_ANDROID if (TCKInput.GetAction("ExplodeButton", EActionEvent.Up)) { player.shockWave(); } #elif UNITY_EDITOR_WIN if (Input.GetKeyDown(dischargeKey)) { player.shockWave(); } #endif //TODO: Draw spawn circle, circle has performance issues!? if (!characterController.isGrounded) { //Only ray to the boundary layer RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), out hit, Mathf.Infinity, (1 << LayerMask.NameToLayer("Boundary")))) { Debug.Log("hit"); Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.down) * hit.distance, Color.yellow); //Utilities.DrawCircle(spawnCircle, spawnCircleWidth, 0.2f, false); //spawnCircle.transform.position = hit.point; //spawnCircleLine.enabled = true; } } }
// Update is called once per frame void Update() { if (TCKInput.GetAction("Answer1", EActionEvent.Click)) { Debug.Log("Answer1"); answers[current++] = "1"; } if (TCKInput.GetAction("Answer2", EActionEvent.Click)) { Debug.Log("Answer2"); answers[current++] = "2"; } if (TCKInput.GetAction("Answer3", EActionEvent.Click)) { Debug.Log("Answer3"); answers[current++] = "3"; } if (TCKInput.GetAction("Answer4", EActionEvent.Click)) { Debug.Log("Answer4"); answers[current++] = "4"; } if (TCKInput.GetAction("Answer5", EActionEvent.Click)) { Debug.Log("Answer5"); answers[current++] = "5"; } if (TCKInput.GetAction("AnswerOK", EActionEvent.Click)) { TMP_Dropdown dd1 = GameObject.Find("Dropdown1").GetComponent <TMP_Dropdown>(); TMP_Dropdown dd2 = GameObject.Find("Dropdown2").GetComponent <TMP_Dropdown>(); TMP_Dropdown dd3 = GameObject.Find("Dropdown3").GetComponent <TMP_Dropdown>(); if (dd1.value != 0 && dd2.value != 0 && dd3.value != 0) { Debug.Log("Answer5 - " + dd1.value.ToString() + "," + dd2.value.ToString() + "," + dd3.value.ToString()); answers[current++] = dd1.value.ToString() + "," + dd2.value.ToString() + "," + dd3.value.ToString(); } } if (current + 1 >= 9) { Debug.Log("Survey finished"); string id = SystemInfo.deviceUniqueIdentifier; StreamWriter wr = new StreamWriter(Application.persistentDataPath + "/" + id + "/" + "SURVEY_ANSWERS.txt", false); foreach (string ans in answers) { wr.Write(ans); wr.Write("\n"); } wr.Close(); SceneManager.LoadScene("Upload", LoadSceneMode.Single); } if (previous != current) { SceneManager.LoadScene("Survey" + (current + 1).ToString(), LoadSceneMode.Single); } }
// Update is called once per frame void Update() { defence = Input.GetKey(keyB) || TCKInput.GetAction("defenceBtn", EActionEvent.Press);; run = Input.GetKey(keyD) || TCKInput.GetAction("runBtn", EActionEvent.Press); //bool newjump = Input.GetKey(keyA); //if(newjump == true && newjump != lastjump) //{ // jump = true; //} //else //{ // jump = false; //} //lastjump = newjump; trigger(keyA, "jumpBtn", ref lastjump, ref jump); trigger(keyC, "attackBtn", ref lastattack, ref attack); if (MouseEnable == true) { //Jup = (Input.GetKey(keyJUp) ? 1.0f : 0) - (Input.GetKey(keyJDown) ? 1.0f : 0); //Jright = (Input.GetKey(keyJLeft) ? 0 : 1.0f) - (Input.GetKey(keyJRight) ? 0 : 1.0f); Jup = Input.GetAxis("Mouse Y") * 3.5f; Jright = Input.GetAxis("Mouse X") * 2.5f; targetDup = (Input.GetKey(keyUp) ? 1.0f : 0) - (Input.GetKey(keyDown) ? 1.0f : 0); targetDright = (Input.GetKey(keyLeft) ? 0 : 1.0f) - (Input.GetKey(keyRight) ? 0 : 1.0f); } else { Vector2 look = TCKInput.GetAxis("Touchpad"); Jup = look.y; Jright = look.x; Vector2 move = TCKInput.GetAxis("Joystick"); // NEW func since ver 1.5.5 targetDup = move.y; targetDright = move.x; } if (inputeEnabled == false) { targetDup = 0; targetDright = 0; } Dup = Mathf.SmoothDamp(Dup, targetDup, ref velocityDup, 0.1f); Dright = Mathf.SmoothDamp(Dright, targetDright, ref velocityDright, 0.1f); if (MouseEnable == false) { Vector2 temp = SquareToCircle(new Vector2(Dup, Dright)); Dup = temp.x; Dright = temp.y; } Dmag = Mathf.Sqrt(Dup * Dup + Dright * Dright); Dvec = Dright * transform.right + Dup * transform.forward; }
void Update() { if (TCKInput.GetAction("leavecarBtn", EActionEvent.Down)) { LeaveCar(); } if (TCKInput.GetAction("getcarBtn", EActionEvent.Down)) { GoToCar(); } if (characher.activeSelf) { car = FindCar(); if (car != null && profile.Cars.Contains(car)) { TCKInput.SetControllerEnable("getcarBtn", true); } else { TCKInput.SetControllerEnable("getcarBtn", false); } } }
// Update is called once per frame void LateUpdate() { float horizontal = TCKInput.GetAxis("Joystick", EAxisType.Horizontal); if (horizontal < 0) { transform.localScale = new Vector3(-scale.x, transform.localScale.y, transform.localScale.z); } else if (horizontal > 0) { transform.localScale = new Vector3(scale.x, transform.localScale.y, transform.localScale.z); } if (horizontal != 0 && isWalking == false && !isFlying) { Anim.SetTrigger("4Walk"); isWalking = true; } if (horizontal == 0 && isWalking == true) { Anim.SetTrigger("4Idle"); isWalking = false; } if (TCKInput.GetAction("jumpBtn", EActionEvent.Down)) { Anim.SetTrigger("4Jump"); isFlying = true; } }
// Update void Update() { if (weapReady == false) { weapReadyTime += Time.deltaTime; if (weapReadyTime > .15f) { weapReady = true; weapReadyTime = 0f; } } if (TCKInput.GetAction("jumpBtn", EActionEvent.Down)) { Jumping(); } if (TCKInput.GetAction("fireBtn", EActionEvent.Press)) { PlayerFiring(); } Vector2 look = TCKInput.GetAxis("Touchpad"); PlayerRotation(look.x, look.y); }
void Update() { rb.velocity = new Vector2(TCKInput.GetAxis("Joystick", EAxisType.Horizontal) * Speed, rb.velocity.y);; if (TCKInput.GetAction("jumpBtn", EActionEvent.Down)) { rb.AddForce(Vector2.up * Jumpforce, ForceMode2D.Impulse); } }
// Update void Update() { grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Default")); if (TCKInput.GetAction("jumpButton", EActionEvent.Down) && grounded) { jump = true; } }
// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonOK", EActionEvent.Click)) { if (uploadSuccessfull) { SceneManager.LoadScene("MainMenu", LoadSceneMode.Single); } } }
void trigger(string key, string buttonname, ref bool lastvalue, ref bool value) { bool newjump = (Input.GetKey(key) || TCKInput.GetAction(buttonname, EActionEvent.Down)); if (newjump == true && newjump != lastvalue) { value = true; } else { value = false; } lastvalue = newjump; }
// Update is called once per frame void Update() { if (TCKInput.GetAction("fireBtn", EActionEvent.Down)) { hornetController.FirePlasma(); } if (TCKInput.GetAction("tunnelBtn", EActionEvent.Press)) { hornetController.ExitButtonPressed = true; } else { hornetController.ExitButtonPressed = false; } }
// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonStart", EActionEvent.Click)) { SceneManager.LoadScene("World", LoadSceneMode.Single); } if (TCKInput.GetAction("ButtonCredits", EActionEvent.Click)) { SceneManager.LoadScene("Credits", LoadSceneMode.Single); } if (TCKInput.GetAction("ButtonExit", EActionEvent.Click)) { Application.Quit(); } }
public void Update() { if (WorldController.Instance.gameMode == GameMode.PlayMode) { // Get joystick move and update Animator Vector2 move = TCKInput.GetAxis("Joystick"); joyMoveDT = new Vector3(move.x, 0, move.y); playerAnim.SetFloat("speed", joyMoveDT.magnitude); // get canMove from player Animator bool canMove = playerAnim.GetBool("canMove"); // Get button press pressedAttack = TCKInput.GetAction("AtkButton", EActionEvent.Down); if (pressedAttack) { ATKOn = true; } // Set ATK with interval time if (ATKOn //&& canMove ) { ATKtimecounter += Time.deltaTime; //Debug.Log(ATKtimecounter); if (ATKtimecounter < p.ATKAnimTime) { if (normalAttack == false) { PlayerNormalAttack(); } } else if (ATKtimecounter >= p.ATKIntervalTime + p.ATKAnimTime) { ATKtimecounter = 0; ATKOn = false; } else { // Not Attack } } //camController.MoveCamOnPlayerMove(move); } }
void Update() { timer -= Time.deltaTime; timerTxt.text = "Time: " + Mathf.Floor(timer / 60).ToString("00") + ":" + (timer % 60).ToString("00"); if (TCKInput.GetAction("PauseBtn", EActionEvent.Down)) { GamePauseBtn(); } if (TCKInput.GetAction("GameReloadBtn", EActionEvent.Down)) { GameReloadLevelBtn(); } if (TCKInput.GetAction("BackToMenuBtn", EActionEvent.Down)) { BackToMenuBtn(); } }
// Update void Update() { if (TCKInput.GetAction("shootButton", EActionEvent.Down)) { anim.SetTrigger("Shoot"); if (playerCtrl.facingRight) { Rigidbody2D bulletInstance = Instantiate(rocket, transform.position, Quaternion.Euler(Vector3.zero)) as Rigidbody2D; bulletInstance.velocity = new Vector2(speed, 0f); } else { Rigidbody2D bulletInstance = Instantiate(rocket, transform.position, Quaternion.Euler(new Vector3(0f, 0f, 180f))) as Rigidbody2D; bulletInstance.velocity = new Vector2(-speed, 0f); } } }
public void Update() { if (WorldController.Instance.gameMode == GameMode.PlayMode) { // Get joystick move and update Animator Vector2 move = TCKInput.GetAxis("Joystick"); joyMoveDT = new Vector3(move.x, 0, move.y); playerAnim.SetFloat("speed", joyMoveDT.magnitude); // get canMove from player Animator bool canMove = playerAnim.GetBool("canMove"); // Get button press pressedAttack = TCKInput.GetAction("AtkButton", EActionEvent.Down); if (pressedAttack && canMove) { PlayerNormalAttack(); } //camController.MoveCamOnPlayerMove(move); } }
// Update is called once per frame void Update() { Camera.main.transform.position = new Vector3(player.transform.position.x, Camera.main.transform.position.y, Camera.main.transform.position.z); if (TCKInput.GetAction("leftBtn", EActionEvent.Press)) { Izquierda(); } if (TCKInput.GetAction("rightBtn", EActionEvent.Press)) { Derecha(); } if (TCKInput.GetAction("upBtn", EActionEvent.Press)) { Arriba(); } if (TCKInput.GetAction("downBtn", EActionEvent.Press)) { Abajo(); } }
protected override void Update() { if (GameSystem.instance.gameState == GameState.Start) { if (atkCountingTime > 0) { atkCountingTime -= Time.deltaTime; } if (TCKInput.GetAction("fireBtn", EActionEvent.Click)) { if (target) { state = "Attack"; } else if (moveTarget) { state = "MoveToTarget"; } else { StartCoroutine(ResetTrigger()); } } if (TCKInput.GetAction("skillBtn-1", EActionEvent.Click)) { GetComponent <SkillList>().UseSkill(0); } if (TCKInput.GetAction("skillBtn-2", EActionEvent.Click)) { GetComponent <SkillList>().UseSkill(1); } if (TCKInput.GetAction("skillBtn-3", EActionEvent.Click)) { GetComponent <SkillList>().UseSkill(2); } if (state == "Standby") { if (isMovement) { if (moveTarget) { state = "MoveToTarget"; } if (target) { state = "Attack"; } } } else if (state == "Control") { } else if (state == "MoveToTarget") { if (isMovement) { if (moveTarget) { transform.LookAt(new Vector3(moveTarget.transform.position.x, transform.position.y, moveTarget.transform.position.z), Vector3.up); //transform.position = Vector3.MoveTowards(transform.position, moveTarget.transform.position, characterMovement.playerSpeed); Vector3 move = (moveTarget.transform.position - transform.position).normalized; characterMovement.controller.Move(move * Time.deltaTime * characterMovement.playerSpeed); } } } else if (state == "Attack") { if (target) { transform.LookAt(new Vector3(target.transform.position.x, transform.position.y, target.transform.position.z), Vector3.up); if (atkCountingTime <= 0) { AttackNow(); atkCountingTime = atkSpeed; } if (targetStatus.CheckDead()) { target = null; //state = "Standby"; StartCoroutine(ResetTrigger()); } } } } }
void Update() { if (!GetComponent <CarProfile>().isActive) { FMotor.motorSpeed = 0; RMotor.motorSpeed = 0; FWheel.motor = FMotor; RWheel.motor = RMotor; return; } FWheel.motor = FMotor; RWheel.motor = RMotor; float horizontal = TCKInput.GetAxis("Joystick", EAxisType.Horizontal); if (horizontal < 0 && rb.velocity.x < 0) { transform.localScale = new Vector3(-scale.x, transform.localScale.y, transform.localScale.z); } else if (horizontal > 0 && rb.velocity.x > 0) { transform.localScale = new Vector3(scale.x, transform.localScale.y, transform.localScale.z); } float radius = GetComponentInChildren <CircleCollider2D>().radius *transform.localScale.y *GetComponentsInChildren <Transform>()[1].localScale.y; Speed = 180 / (radius * 10) * Mathf.PI * maxSpeed / 3.6f * -horizontal; txt_speedometr.text = $"{Mathf.Abs(Mathf.RoundToInt(rb.velocity.x * 3.6f))}"; FMotor.motorSpeed = Speed; RMotor.motorSpeed = Speed; RMotor.maxMotorTorque = maxTorque; FMotor.maxMotorTorque = maxTorque; List <int> layers = new List <int> { LayerMask.NameToLayer("Car"), LayerMask.NameToLayer("Ignore Character"), }; if (TCKInput.GetAction("jumpBtn", EActionEvent.Down)) { int lastLayer = -1; foreach (var layer in layers) { Physics2D.IgnoreLayerCollision(layer, layer, true); if (lastLayer != -1) { Physics2D.IgnoreLayerCollision(layer, lastLayer, true); } lastLayer = layer; } } if (TCKInput.GetAction("jumpBtn", EActionEvent.Up)) { int lastLayer = -1; foreach (var layer in layers) { Physics2D.IgnoreLayerCollision(layer, layer, false); if (lastLayer != -1) { Physics2D.IgnoreLayerCollision(layer, lastLayer, false); } lastLayer = layer; } } }
// TouchKit Input private void TouchKitInput() { if (TCKInput.CheckController(actions.pause) && TCKInput.GetAction(actions.pause, TCKActionEvent.Down)) { Pause(); } runAction = (TCKInput.CheckController(actions.run) && TCKInput.GetAction(actions.run, TCKActionEvent.Press)); if (TCKInput.CheckController(actions.jump) && TCKInput.GetAction(actions.jump, TCKActionEvent.Down)) { FirstPersonController.Jump(); } if (TCKInput.CheckController(actions.crouch) && TCKInput.GetAction(actions.crouch, TCKActionEvent.Down)) { FirstPersonController.Crouch(); } if (TCKInput.CheckController(actions.use) && TCKInput.GetAction(actions.use, TCKActionEvent.Down)) { PlayerCamera.UseItem(); } if (TCKInput.CheckController(actions.reloadWeapon) && TCKInput.GetAction(actions.reloadWeapon, TCKActionEvent.Down)) { WeaponsManager.ReloadWeapon(); } if (TCKInput.CheckController(actions.nextFiremode) && TCKInput.GetAction(actions.nextFiremode, TCKActionEvent.Down)) { WeaponsManager.SwitchFiremode(); } if (TCKInput.CheckController(actions.nextAmmotype) && TCKInput.GetAction(actions.nextAmmotype, TCKActionEvent.Down)) { WeaponsManager.SwitchAmmotype(); } if (TCKInput.CheckController(actions.toSubweapon) && TCKInput.GetAction(actions.toSubweapon, TCKActionEvent.Down)) { WeaponsManager.SwitchToSubWeapon(); } if (TCKInput.CheckController(actions.dropWeapon) && TCKInput.GetAction(actions.dropWeapon, TCKActionEvent.Down)) { WeaponsManager.DropCurrentWeapon(); } if (TCKInput.CheckController(actions.prevWeapon) && TCKInput.GetAction(actions.prevWeapon, TCKActionEvent.Down)) { WeaponsManager.SelectPreviousWeapon(); } if (TCKInput.CheckController(actions.nextWeapon) && TCKInput.GetAction(actions.nextWeapon, TCKActionEvent.Down)) { WeaponsManager.SelectNextWeapon(); } if (TCKInput.CheckController(axes.moveJoystick)) { moveHorizontal = Mathf.Clamp(TCKInput.GetAxis(axes.moveJoystick, TCKAxisType.Horizontal), -1f, 1f); moveVertical = runAction ? 1f : Mathf.Clamp(TCKInput.GetAxis(axes.moveJoystick, TCKAxisType.Vertical), -1f, 1f); } if (TCKInput.CheckController(axes.lookTouchpad)) { lookHorizontal = TCKInput.GetAxis(axes.lookTouchpad, TCKAxisType.Horizontal) * GameSettings.GetLookSensitivityByInvert_X; lookVertical = TCKInput.GetAxis(axes.lookTouchpad, TCKAxisType.Vertical) * GameSettings.GetLookSensitivityByInvert_Y; } if (TCKInput.CheckController(actions.zoom)) { zoomAction = TCKInput.GetAction(actions.zoom, TCKActionEvent.Press); zoomActionDown = TCKInput.GetAction(actions.zoom, TCKActionEvent.Down); zoomActionUp = TCKInput.GetAction(actions.zoom, TCKActionEvent.Up); } if (TCKInput.CheckController(actions.fire)) { bool fireAction = TCKInput.GetAction(actions.fire, TCKActionEvent.Press); // Fire and Reset Weapon if (fireAction && !FirstPersonController.isRunning) { WeaponsManager.WeaponFire(); } else { WeaponsManager.WeaponReset(); } } }
void FixedUpdate() { if (locked) { return; } grounded = checkIfGrounded(); running = false; idleTimer += Time.fixedDeltaTime; Turning(); if (checkMovementButtons() < 0.0f) { if (rotationY > -90.0f) { turningLeft = true; } else { rotationY = -90.0f; running = true; } } else if (checkMovementButtons() > 0.0f) { if (rotationY < 90.0f) { turningRight = true; } else { rotationY = +90.0f; running = true; } } else { moveVector = Vector3.zero; running = false; } transform.rotation = Quaternion.Euler(0, rotationY, 0); // If player is grounded there should be no vertical speed if (grounded && !jumping) { verticalSpeed = 0.0f; } if ((grounded || jumping) && running) { idleTimer = 0.0f; moveVector.x = checkMovementButtons(); moveVector.y = verticalSpeed; moveVector.z = 0.0f; moveVector *= runningForce; runningSpeed = moveVector.x; if (grounded && !jumping) // Player is moving on the ground { m_Animator.SetBool("run", true); } } else { m_Animator.SetBool("run", false); } if (jump && !grounded) { jump = false; } // Player has landed on the ground if (jumping && grounded && !jump) { m_Animator.SetBool("jump", false); jumping = false; jumpOnPlace = false; m_CharacterController.detectCollisions = true; } // Player has pressed the jump button if ((Input.GetKey(KeyCode.UpArrow) || TCKInput.GetAction("ButtonJump", EActionEvent.Down)) && grounded) { jumping = true; } // Player has pressed the jump button and is grounded -> start jump if (grounded && jumping) { idleTimer = 0.0f; m_Animator.SetBool("jump", true); logger.LogPlayerJump(transform.position, Game.GetComponent <AssignController>().controllerNum); if (running) // Player will jump while running, set speed without delay { m_CharacterController.detectCollisions = false; verticalSpeed = jumpForce; jump = true; } else // Player will jump on place, initialize "jump delay" { //verticalSpeed = jumpForce; //jumping = true; jumpDelay = jumpDelayDef; jumpOnPlace = true; jumping = false; jump = true; } } // Player has not pressed any button in more than five seconds -> start "bored" animation if (idleTimer > 5.0f) { m_Animator.SetBool("idle", true); } else { m_Animator.SetBool("idle", false); } if (!jumping && jumpOnPlace && jumpDelay <= 0) { jumping = true; verticalSpeed = jumpForce; m_CharacterController.detectCollisions = false; } else if (!jumping && jumpOnPlace && jumpDelay > 0) { jumpDelay = jumpDelay - 1; } if (!m_Animator.GetCurrentAnimatorStateInfo(0).IsName("AnimationPlayerAttack")) { m_Animator.SetBool("attack", false); attack = false; } else { verticalSpeed = 0.0f; moveVector.x += 0.175f; } // Player has pressed an action button -> start "attack" animation if ((Input.GetKey(KeyCode.DownArrow) || TCKInput.GetAction("ButtonAttack", EActionEvent.Down)) && grounded && !jumping && !jumpOnPlace && !attack) { logger.LogPlayerAttack(transform.position, Game.GetComponent <AssignController>().controllerNum); m_Animator.Play("AnimationPlayerAttack"); m_Animator.SetBool("attack", true); attack = true; } verticalSpeed -= gravity * Time.fixedDeltaTime; moveVector.y = verticalSpeed; m_CharacterController.Move(moveVector * Time.fixedDeltaTime); // Because some animations move the player along all axes, reset Z axis. LockZAxis(10.0f); }