27 lines
652 B
C#
27 lines
652 B
C#
using UnityEngine;
|
|
|
|
public class Player_01 : MonoBehaviour
|
|
{
|
|
public float racketSpeed;
|
|
public string Inputname;
|
|
private Rigidbody2D rb;
|
|
private Vector2 racketDirection;
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
void Start()
|
|
{
|
|
rb = GetComponent<Rigidbody2D>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
float directionY = Input.GetAxisRaw(Inputname);
|
|
|
|
racketDirection = new Vector2(0,directionY).normalized;
|
|
}
|
|
private void FixedUpdate()
|
|
{
|
|
rb.linearVelocity = racketDirection * racketSpeed;
|
|
}
|
|
}
|