Help with a ScreenToWorldPoint Issue across devices...

Hi Everyone,

I’m hoping someone can help me with a strange issue with this section of my code.

        if (hasWarped == false && currentWarp > 0)
        {

            if (Input.touches [0].tapCount == 2)
            {
                Debug.Log (currentWarp);
                Vector3 target = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 10.0f));
                character.transform.Translate (Vector3.MoveTowards (character.transform.position, target, warpSpeed * Time.deltaTime) - character.transform.position);
                removeLife ();
            }

so ive been testing this on my phone (HTC 626) and when you double tap on the screen it moves the object to that position… all works fine on my device

But.

Yesterday i decided to give it a quick test on my partners phone (Samsung S7) and when i double tap on the screen the object moves to the tapped position but the next frame it snaps back to the old position.

I’m currently lost on what could be the issue here.

HELP :slight_smile:

Anyone?

Code looks ok to me but I think it might be an issue with your Time.deltaTime? It might be different on different phones so maybe that’ll cause problems with the movement.

Thanks tonemcbride, Thats a good idea to check the Time.deltaTime i will do this first.

After going through the code some more i found that if i disable this section of code the tap to move works on both devices. but obviously i loose some functionality that i need.

BUT. ill give the Time.deltaTime a look at first, fingers crossed that is the issue.

        if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began)
        {
            lastTouchPosition = Camera.main.ScreenToWorldPoint (shipPos) - character.transform.position;   // This line breaks S7
        }