Player control does't work

Control of player doesn’t work Screenshot by Lightshot
And i don’t see message on console of controls.

Hi,

Welcome to our community! :slight_smile:

In which course and lecture are you?

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:


See also;

I know the new input system can call methods/fire events on scripts and I won’t see this in the code, but from what I can see, there’s nothing calling OnMove so it won’t change rawInput and it won’t log anything to the console

Complete C# Unity Game Developer 2D

Laser Defender - №113.

Player - Screenshot by Lightshot
Input actions - Screenshot by Lightshot
Screenshot by Lightshot - input system

Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class Player : MonoBehaviour
{

Vector2 rawInput;
void Update()
{
    Vector3 delta = rawInput;
    transform.position += delta;
}

void OnMove(InputValue value)    
{
    rawInput = value.Get<Vector2>();
    Debug.Log(rawInput);
}

}

When i press play, player movement doesn’t work… and i don’t see any think in console Collapse

Thank you. The problem is very likely this component:

image

Acutally, the actions should be listed there. Did you create an Input Action Asset? If so, assign it to the Actions field. That field currently says “None” in your screenshot.

I don’t understand what i need to click and what to choose? I make all like on tutorial

Your last screenshot shows what I meant. Did you do that?

If so, to which game object did you attach the Player script? The PlayerInput component must be attached to the same game object as your Player component.

Privacy & Terms