Quantcast
Viewing latest article 18
Browse Latest Browse All 154

Tap&Hold Android Game - weird problem with touch

Hello. Im making android game with tap and hold mechanics - when you tap and hold finger on your screen, the spaceship is flying. If there is no finger on screen - the spaceship i falling. I have experienced weird problem during tests - sometimes (not always, but often) after removing finger from screen, my spaceship "jumps" which often results in loosing game (becasue this "jump" moved spaceship into obstacle). I dont have idea what could be wrong with this, especially, that it is not always. Maybe refreshing? Maybe something with framerate? Please help me! Code is below, this "if" with 1 or more fingers i have added later, problem isnt caused by this. If you want to see this in practise i can give you .apk file. public float TapSpeed = 10; public float TapSpeed2 = 200; public float tilt = 5; public float tilt2 = 5; Rigidbody2D rigid; Quaternion downRotation; Quaternion forwardRotation; void Update () { if (game.GameOver) return; if (Input.touchCount > 0) { //if (Input.GetMouseButtonDown(0)) { tap.Play(); BloomModel.Settings bloomSettings = zxc.bloom.settings; bloomSettings.bloom.intensity = Mathf.SmoothDamp(2,5, ref yVelocity, smoothTime); zxc.bloom.settings = bloomSettings; transform.rotation = forwardRotation; rigid.velocity = Vector3.zero; rigid.AddForce(Vector2.up * TapSpeed); //,ForceMode2D.Force); } if (Input.touchCount > 1) { //if (Input.GetMouseButtonDown(0)) { tap.Play(); transform.rotation = forwardRotation; rigid.velocity = Vector3.zero; rigid.AddForce(Vector2.up * TapSpeed2); //,ForceMode2D.Force); } BloomModel.Settings bloomSettingss = zxc.bloom.settings; bloomSettingss.bloom.intensity = Mathf.SmoothDamp(5,2, ref yVelocity, smoothTime); zxc.bloom.settings = bloomSettingss; transform.rotation = Quaternion.Lerp(transform.rotation, downRotation, tilt * Time.deltaTime); }

Viewing latest article 18
Browse Latest Browse All 154

Trending Articles