W
W
WasTabon2020-11-02 18:13:38
Unity
WasTabon, 2020-11-02 18:13:38

Why is the click method not working? InputValue?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.PlayerLoop;

public class TapMoving : MonoBehaviour
{
    public Variables variables;
    public Vector2 vector2;
    public Vector2 playerVector;
    public GameObject objectThis;

    public void Move(InputValue value)
    {
        Debug.Log(123);
        vector2 = value.Get<Vector2>();
        objectThis.transform.position = new Vector3(vector2.x, vector2.y, 1);
    }
}


Download this in package manager

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Fobius, 2020-11-02
@WasTabon

Friend, if the game is for mobile phones, then this needs to be added and implemented then, see:

public class Click : MonoBehaviour , IPointerHandler{


    public void OnPointerUp(PointerEventData eventData)
    {		    
        персонаж.что-то там туда сюда // к примеру сделал что-то
    }

    public void OnPointerDown(PointerEventData eventData)
    {
       персонаж.перестал свое что-то там туда сюда // перестал делать это что-то
    }

I’m writing from memory, so what if something’s wrong, I’m sorry
if it’s for a computer, then:
create a button through UI> Button
add an Event Trigger
to it further look in it and poke Pointer Up
add the script itself there, like this for example:
public void Onclick()
  {
    ну вот что-то там где-то сработало
  }

after which another button will appear, you press and look for the method that you need to execute when you click (well, I have it Onclick() ), and everything, in fact, works!
(I repeat, I'm sorry if it's wrong, I'm doing it from memory, recently I just finished such a project)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question