I’m in the process of making my gameobject move when I drag it across the screen on touch. But my current issue is when I press play to test the game, game object snaps to the size of my camera on the Y. The camera by default is set to a size of “5”. The game object will jump to the “5” position on play. I cannot figure out why. Instead of the object staying at the -4.5f like I have in the Vector3, it jumps to the camera size.
Here is what I have:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PaddlePosition : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
OnFingerDrag();
}
private void OnFingerDrag()
{
Vector3 fingerPosition = new Vector3(Input.mousePosition.x, -4.5f, 0.0f);
Vector3 objectPosition = Camera.main.ScreenToWorldPoint(fingerPosition);
transform.position = objectPosition;
}
}