#Input System problem (TRIGGER WARNING: I'M NEW)
1 messages · Page 1 of 1 (latest)
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
Rigidbody2D rb;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
if (Keyboard.current.upArrowKey.isPressed)
{
rb.AddForce(transform.up);
Debug.Log("W");
}
}
}
It doesn't Debug.Log W
I followed an tutorial
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
also what button are you pressing on your keyboard
The UpArrowKey
wait imma make the code
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour
{
Rigidbody2D rb;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
if (Keyboard.current.upArrowKey.isPressed)
{
rb.AddForce(transform.up);
Debug.Log("W");
}
}
}
It doesn't Debug.Log W
I followed an tutorial
is the component attached to an active object in the scene
The RigidBody2D is attached to the main plaer ( a rocket ) .
that's not what i asked. i asked about this component
!learn 👇 start by learning how to actually use the engine instead of skipping ahead to tutorials that don't teach you the absolute basics
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!