Hello I keep gettin null error. I don’t know how to solve. Code is the exact same. Can you help ?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private Camera mainCamera;
void Start()
{
mainCamera = Camera.main;
}
// Update is called once per frame
private void Update()
{
if (Touchscreen.current.primaryTouch.press.isPressed)
{
Vector2 touchPos = Touchscreen.current.primaryTouch.position.ReadValue();
print(touchPos);
Vector3 worldPosition = mainCamera.ScreenToWorldPoint(touchPos);
print(worldPosition);
}
}
}