- Home /
Question by
KenMista · Jul 29, 2020 at 04:40 PM ·
movementinputmovement script
How can I smooth out and unlock the movement with the input system?
I'm a beginner to unity and I'm trying out the input system. https://gyazo.com/27409be10a2508c75b381c2f4538a82f This is whats happening. . . . . using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem;
public class PlayerMovement : MonoBehaviour { private PlayerInputs controls;
public float moveSpeed;
public Rigidbody2D rb;
Vector2 movement;
private void Awake()
{
controls = new PlayerInputs();
}
private void OnEnable()
{
controls.Enable();
}
private void OnDisable()
{
controls.Disable();
}
private void Update()
{
movement = controls.Controls.Movement.ReadValue<Vector2>() * moveSpeed;
transform.position = movement * Time.deltaTime;
}
private void FixedUpdate()
{
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
How to get Horizontal axis value to 0 instantly after releasing the positive button!!!! 0 Answers
New Input System 'Started' and 'Performed' actions fire at the same time? 1 Answer
Why is my character so slow? 1 Answer
Character won't jump under certain circumstances 0 Answers
Add keyboard input in ClickToMove 0 Answers