Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PaddleController : MonoBehaviour {
- public enum Player {
- PLAYER_ONE,
- PLAYER_TWO
- }
- public Player CurrentPlayer;
- public float Speed;
- void Update() {
- Vector3 movement = this.transform.position;
- float moveSpeed = Speed * Time.deltaTime;
- if(CurrentPlayer == Player.PLAYER_ONE) {
- if(Input.GetKey(KeyCode.W)) {
- movement.y += moveSpeed;
- } else if (Input.GetKey(KeyCode.S)) {
- movement.y -= moveSpeed;
- }
- } else {
- if(Input.GetKey(KeyCode.UpArrow)) {
- movement.y += moveSpeed;
- } else if (Input.GetKey(KeyCode.DownArrow)) {
- movement.y -= moveSpeed;
- }
- }
- this.transform.position = movement;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement