Advertisement
drakon-firestone

PaddleScript

May 8th, 2023
728
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. public class PongPaddle : MonoBehaviour
  2. {
  3.     [SerializeField] private float speed = 5f;
  4.  
  5.     [Range(1, 2)]
  6.     [SerializeField] private int playerNumber = 1;
  7.  
  8.     private void Update()
  9.     {
  10.         Move();
  11.     }
  12.  
  13.     private void Move()
  14.     {
  15.         float y = Input.GetAxisRaw("Vertical" + playerNumber);
  16.  
  17.         float speedDir = y * speed * Time.deltaTime;
  18.         transform.position += new Vector3(0, speedDir, 0);
  19.     }
  20. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement