SHOW:
|
|
- or go back to the newest paste.
1 | using System.Collections; | |
2 | using System.Collections.Generic; | |
3 | using UnityEngine; | |
4 | ||
5 | public class PongPaddle : MonoBehaviour | |
6 | { | |
7 | //Prędkość naszej paletki | |
8 | public float speed = 5f; | |
9 | ||
10 | [Range(1, 2)] | |
11 | public int playerNumber = 1; | |
12 | ||
13 | ||
14 | void Update() | |
15 | { | |
16 | Move(); | |
17 | } | |
18 | ||
19 | //funkcja odpowiedzialna za ruch | |
20 | void Move() | |
21 | { | |
22 | //Zczytujemy z GetAxisRaw w którą stronę chcemy się poruszać i którym graczem | |
23 | float y = Input.GetAxisRaw("Vertical" + playerNumber); | |
24 | ||
25 | float speedDir = y * speed * Time.deltaTime; | |
26 | transform.position += new Vector3(0, speedDir, 0); | |
27 | ||
28 | ||
29 | } | |
30 | } | |
31 |