This question was
closed Sep 14, 2020 at 08:42 AM by
unity_jNJGa9C_QemzOQ for the following reason:
I have solved the problem, and the tutorial show be updated since I think I is a missing step
Question by
unity_jNJGa9C_QemzOQ · Sep 16, 2020 at 07:58 PM ·
inputtutorialroll a ball
the ball(Player) in roll a ball tutorial won't move
I am following the tutorial exactly
here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
public float speed = 0;
private Rigidbody rb;
private float movementX;
private float movementY;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
private void OnMove(InputValue movementValue)
{
Vector2 movementVector = movementValue.Get<Vector2>();
movementX = movementVector.x;
movementY = movementVector.y;
Debug.Log("I am called!!!!!!!!!!!!!");
}
private void FixedUpdate()
{
Debug.Log("movementX = " + movementX);
Debug.Log("movementY = " + movementY);
Vector3 movement = new Vector3(movementX, 0.0f, movementY);
rb.AddForce(movement * speed);
}
}
I found that the movementX and movementY are always 0, which mean the editor do not receive my input(left, right, up, down as well as WSAD), and seems the the OnMove function is not called
Anyone has idea about this, I am new to Unity
Comment
I found that the tutorial missing one action so that I cannot receive the input
in the PlayInput action, select InputAction then default scheme select Keyboard&$$anonymous$$ouse
after that it works
Have exact same issue, On$$anonymous$$ove() is just not called, no error. Were you able to solve it?
Try
public void On$$anonymous$$ove(InputValue movementValue)