W
W
WasTabon2020-11-03 17:17:58
Unity
WasTabon, 2020-11-03 17:17:58

How to get click coordinates in Unity's new input system?

public void Tap(InputAction.CallbackContext context)
    {
        Debug.Log("Tap");
    }

5fa1668ba01b8172217589.png
How?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WasTabon, 2020-11-03
@WasTabon

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class TapMoving : MonoBehaviour
{
    public Camera cam;
    public Variables variables;
    public Vector2 vector2;
    public Vector2 playerVector;
    public GameObject objectThis;

    public void Tap(InputAction.CallbackContext context)
    {
        Debug.Log(Mouse.current.position.x.ReadValue());
        objectThis.transform.position = cam.ScreenToWorldPoint (new Vector3(Mouse.current.position.x.ReadValue(), Mouse.current.position.y.ReadValue(), 1));
    }

Made

G
GavriKos, 2020-11-03
@GavriKos

Read documentation?
https://docs.unity3d.com/Packages/com.unity.inputs...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question