// 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 FixedUpdate() { //Android joystick or Windows arrow controls Vector2 move = Vector2.zero; #if UNITY_ANDROID move = TCKInput.GetAxis("Joystick"); #elif UNITY_EDITOR_WIN if (Input.GetKey(upKey)) { move = Vector2.up; } else if (Input.GetKey(downKey)) { move = Vector2.down; } if (Input.GetKey(leftKey)) { move += Vector2.left; } else if (Input.GetKey(rightKey)) { move += Vector2.right; } #endif //Player movement in the air while spawning if (!characterController.isGrounded) { move.x *= 4; move.y *= 4; } movePlayer(move.x, move.y); }
// Update is called once per frame void Update() { if (isMainMenu) { if (TCKInput.GetButtonDown("btnFps")) { Application.LoadLevel("FirstPerson"); } // if (TCKInput.GetButtonDown("btnPlatf")) { Application.LoadLevel("2DPlatformer"); } // if (TCKInput.GetButtonDown("btnBal")) { Application.LoadLevel("TiltBallDemo"); } // if (TCKInput.GetButtonDown("btnCar")) { Application.LoadLevel("WheelCarDemo"); } } else { // if (TCKInput.GetButtonUp("mButton")) { Application.LoadLevel("mainMenu"); } } }
// Sens private void Sens(string ctrlName) { float sensitivity = TCKInput.GetSensitivity(ctrlName); sensitivity = customSlider("Sensitivity", sensitivity, 1f, 10f); TCKInput.SetSensitivity(ctrlName, sensitivity); }
// 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); }
private void Update() { Vector2 look = TCKInput.GetAxis("Touchpad"); this.transform.Rotate(Vector3.up * look.x * 500 * Time.deltaTime); cam.transform.Rotate(Vector3.left * look.y * 500 * Time.deltaTime); Vector3 currentRotation = cam.transform.localRotation.eulerAngles; currentRotation.x = Mathf.Clamp(currentRotation.x, minRotation, maxRotation); cam.transform.localRotation = Quaternion.Euler(currentRotation); if (Input.GetKeyDown(KeyCode.Q)) { StartCoroutine(laserCoroutine()); } if (Input.GetKeyDown(KeyCode.T)) { this.gameObject.GetComponent <Animator>().SetBool("carry", true); GameObject x = Instantiate(carrylady, carryladypos.transform.position, carryladypos.transform.rotation) as GameObject; x.transform.SetParent(Carry_Parent.transform); } }
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("ButtonReturn", EActionEvent.Click)) { SceneManager.LoadScene("MainMenu", LoadSceneMode.Single); } }
// FixedUpdate void FixedUpdate() { if (axesInputType == AxesInputType.BindAxes && !binded) { TCKInput.BindAxes("Joystick", BindPlayerAxes); binded = true; return; } if (axesInputType != AxesInputType.BindAxes && binded) { TCKInput.UnbindAxes("Joystick", BindPlayerAxes); binded = false; return; } if (axesInputType != AxesInputType.GetAxis) { return; } float moveX = TCKInput.GetAxis("Joystick", EAxisType.Horizontal); float moveY = TCKInput.GetAxis("Joystick", EAxisType.Vertical); PlayerMovement(moveX, moveY); }
// FixedUpdate void FixedUpdate() { if (axesInputType == AxesInputType.BindAxes && !binded) { TCKInput.BindAxes("Joystick", BindPlayerAxes); binded = true; return; } if (axesInputType != AxesInputType.BindAxes && binded) { TCKInput.UnBindAxes("Joystick", BindPlayerAxes); binded = false; return; } if (axesInputType != AxesInputType.GetAxis) { return; } if (axesGetType == GetAxesMethod.GetByName) { float moveX = TCKInput.GetAxis("Joystick", "Horizontal"); float moveY = TCKInput.GetAxis("Joystick", "Vertical"); PlayerMovement(moveX, moveY); } else { float moveX = TCKInput.GetAxis("Joystick", AxisType.X); float moveY = TCKInput.GetAxis("Joystick", AxisType.Y); PlayerMovement(moveX, moveY); } }
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; } }
// FixedUpdate void FixedUpdate() { float horizontal = TCKInput.GetAxis("DPad", AxisType.X); horizontal = Mathf.Clamp(horizontal, -1f, 1f); anim.SetFloat("Speed", Mathf.Abs(horizontal)); if (horizontal * m_Rigidbody2D.velocity.x < maxSpeed) { m_Rigidbody2D.AddForce(Vector2.right * horizontal * moveForce); } if (Mathf.Abs(m_Rigidbody2D.velocity.x) > maxSpeed) { m_Rigidbody2D.velocity = new Vector2(Mathf.Sign(m_Rigidbody2D.velocity.x) * maxSpeed, m_Rigidbody2D.velocity.y); } if (horizontal > 0f && !facingRight) { Flip(); } else if (horizontal < 0f && facingRight) { Flip(); } if (jump) { anim.SetTrigger("Jump"); m_Rigidbody2D.AddForce(new Vector2(0f, jumpForce * 1.5f)); jump = false; } }
IEnumerator Back() { //玩家与分身初始位置向量获得 Vector2 v = this.transform.position - player.transform.position; while (GetV(v) >= 0.5f) { if (TCKInput.GetTouchPhase("Joystick") == ETouchPhase.NoTouch) { yield return(0); continue; } //玩家与分身位置向量获得 v = this.transform.position - player.transform.position; //分身朝玩家位置移动 transform.Translate(-v * Time.deltaTime * 2); yield return(0); } //分身收回 player.GetComponent <PlayerActivity>().count += 1; //吃掉敌人回复精力值 player.GetComponent <PlayerActivity>().Energy.GetComponent <Energy>().time = 3; //消灭分身object GameObject.Destroy(this.gameObject); }
// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonSurvey", EActionEvent.Click)) { SceneManager.LoadScene("Survey1", LoadSceneMode.Single); } }
void FixedUpdate() { Vector2 move = TCKInput.GetAxis("Joystick0"); Vector3 moveDirection = myTransform.forward * move.x; //moveDirection += myTransform.right * move.y; //player.transform.position = moveDirection; }
// PlayerDie internal static void PlayerDie() { MenuElements.SetActive(true); #if TOUCH_CONTROLS_KIT TCKInput.SetActive(false); #endif }
// Awake void Awake() { myTransform = transform; cameraTransform = Camera.main.transform; controller = this.GetComponent <CharacterController>(); TCKInput.BindAction("jumpBtn", EActionEvent.Down, Jumping); }
// FixedUpdate void FixedUpdate() { /*float moveX = TCKInput.GetAxis( "Joystick", EAxisType.Horizontal ); * float moveY = TCKInput.GetAxis( "Joystick", EAxisType.Vertical );*/ Vector2 move = TCKInput.GetAxis("Joystick"); // NEW func since ver 1.5.5 PlayerMovement(move.x, move.y); }
private static void CreateTouchManager() { TCKInput.CheckUIEventSystem(); if (tckUIobj == null) { TCKInput tckInputObj = Object.FindObjectOfType <TCKInput>(); tckUIobj = (tckInputObj != null) ? tckInputObj.gameObject : null; } if (tckUIobj != null) { UpdateSpritesPath <TCKInput>(tckUIobj); return; } tckUIobj = new GameObject(k_MainGOName, typeof(Canvas), typeof(GraphicRaycaster), typeof(CanvasScaler), typeof(TCKInput)); tckUIobj.layer = LayerMask.NameToLayer("UI"); Transform camTransform = new GameObject("tckUICamera", typeof(GuiCamera)).transform; camTransform.parent = tckUIobj.transform; camTransform.localPosition = Vector3.zero; UpdateSpritesPath <GuiCamera>(camTransform.gameObject); float maxCameraDepth = -1f; Array.ForEach(Object.FindObjectsOfType <Camera>(), cam => maxCameraDepth = Mathf.Max(cam.depth, maxCameraDepth)); Camera camera = camTransform.GetComponent <Camera>(); camera.useOcclusionCulling = false; camera.orthographic = true; camera.allowMSAA = false; camera.allowHDR = false; camera.cullingMask = 32; camera.depth = ++maxCameraDepth; camera.orthographicSize = 100f; camera.nearClipPlane = -.25f; camera.farClipPlane = .25f; camera.renderingPath = RenderingPath.Forward; camera.clearFlags = CameraClearFlags.Depth; Canvas canvas = tckUIobj.GetComponent <Canvas>(); canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = camera; canvas.pixelPerfect = true; CanvasScaler canvasScaler = tckUIobj.GetComponent <CanvasScaler>(); canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand; canvasScaler.referenceResolution = new Vector2(1920, 1080); MarkActiveSceneDirty(); }
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.GetButtonDown("jumpButton") && grounded) { jump = true; } }
// Update is called once per frame void Update() { if (TCKInput.GetAction("ButtonOK", EActionEvent.Click)) { if (uploadSuccessfull) { SceneManager.LoadScene("MainMenu", LoadSceneMode.Single); } } }
public void LeaveCar() { TCKInput.SetControllerEnable("getcarBtn", true); TCKInput.SetControllerEnable("leavecarBtn", false); car.isActive = false; car.tag = "Untagged"; characher.transform.position = car.transform.position; speedcanv.alpha = 0; characher.SetActive(true); }
public void GoToCar() { car.tag = "Player"; car.isActive = true; TCKInput.SetControllerEnable("getcarBtn", false); TCKInput.SetControllerEnable("leavecarBtn", true); speedcanv.alpha = 1; characher.SetActive(false); }
public void Run() { Vector2 move = TCKInput.GetAxis("Joystick"); // NEW func since ver 1.5.5 //if (new Vector2(x, y).sqrMagnitude > 0.01f) //{ for (int i = 0; i < _playerFilter.EntitiesCount; i++) { _playerFilter.Components1[i].Force.X = move.x; _playerFilter.Components1[i].Force.Y = move.y; } //} }
// Update is called once per frame void FixedUpdate() { if (!this.killed) { //Attack if (TCKInput.GetButtonDown("Button0") && Time.time > nextFire) { attack = true; } // Store the input axes. #if UNITY_EDITOR // h = Input.GetAxisRaw("Horizontal"); // v = Input.GetAxisRaw("Vertical"); #endif #if UNITY_ANDROID h = TCKInput.GetAxis("Joystick0", AxisType.X); v = TCKInput.GetAxis("Joystick0", AxisType.Y); #endif // Move the player around the scene. Move(h, v); // Turn the player to face the mouse cursor. Turning(h, v); if (attack) { Shoot(); attack = false; } } else { // Player is dead, play dead sound once... if (!cried) { audio.PlayOneShot(cry); cried = true; } // ... and make it smaller until is almost invisble and destroy it. GetComponent <Animator>().enabled = false; Vector3 scale = transform.localScale; Vector3 newScale = new Vector3(scale.x * 0.95f, scale.y * 0.95f, scale.z * 0.95f); transform.localScale = newScale; if (newScale.x < 0.1f) { gameController.GameOver(); } } }
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; }
private void MovimentarLados() { speedSide = GetComponent <Rigidbody>().velocity.x; float x = TCKInput.GetAxis("Joystick", EAxisType.Horizontal); if (x > 0)//dir { resetSideVelocity = true; GetComponent <Rigidbody>().AddForce(new Vector3(8000 * x * Time.deltaTime, 0, 0)); } if (x < 0) //esq { resetSideVelocity = false; GetComponent <Rigidbody>().AddForce(new Vector3(8000 * x * Time.deltaTime, 0, 0)); } /*if (Input.GetTouch(0).deltaPosition.x > 0) * { * resetSideVelocity = true; * GetComponent<Rigidbody>().AddForce(new Vector3(500, 0, 0)); * } else * if (Input.GetTouch(0).deltaPosition.x < 0) * { * resetSideVelocity = false; * GetComponent<Rigidbody>().AddForce(new Vector3(-500, 0, 0)); * }*/ //limitar movimento laterais--------------------------------------------------------------------------- if (resetSideVelocity == true && speedSide < 0) { GetComponent <Rigidbody>().velocity = new Vector3(0, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z); } if (resetSideVelocity == false && speedSide > 0) { GetComponent <Rigidbody>().velocity = new Vector3(0, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z); } if (speedSide >= limitaVelMax) { //30 max velocidade GetComponent <Rigidbody>().velocity = new Vector3(limitaVelMax, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z); } if (speedSide <= limitaVelMin) { GetComponent <Rigidbody>().velocity = new Vector3(limitaVelMin, GetComponent <Rigidbody>().velocity.y, GetComponent <Rigidbody>().velocity.z); } }