ofb/Assets/Scripts/PlayerController.cs

32 lines
614 B
C#
Raw Normal View History

2023-04-09 21:59:32 -07:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
2023-04-09 21:59:32 -07:00
public class PlayerController : MonoBehaviour
{
Vector2 movementValue;
[SerializeField]
float speed;
[SerializeField]
Rigidbody2D rb;
2023-04-09 21:59:32 -07:00
// Start is called before the first frame update
void Start()
{
}
void OnMove(InputValue value)
{
this.movementValue = value.Get<Vector2>() * speed;
}
2023-04-09 21:59:32 -07:00
// Update is called once per frame
void Update()
{
this.rb.AddForce(new Vector3(this.movementValue.x, 0, this.movementValue.y));
2023-04-09 21:59:32 -07:00
}
}