SHOW:
|
|
- or go back to the newest paste.
| 1 | using System.Collections; | |
| 2 | using System.Collections.Generic; | |
| 3 | using UnityEngine; | |
| 4 | using Photon.Pun; | |
| 5 | ||
| 6 | public class OnlinePaddle : MonoBehaviour | |
| 7 | {
| |
| 8 | //PhotonView, posłuży do sprawdzenia, którą instancją jesteśmy | |
| 9 | public PhotonView myPV; | |
| 10 | public float speed = 5f; | |
| 11 | ||
| 12 | private void Start() | |
| 13 | {
| |
| 14 | myPV = GetComponent<PhotonView>(); | |
| 15 | } | |
| 16 | void Update() | |
| 17 | {
| |
| 18 | //Sprawdzenie czy element w grze jest nasz (lokalnego gracza) | |
| 19 | if (myPV.IsMine) | |
| 20 | {
| |
| 21 | Move(); | |
| 22 | } | |
| 23 | ||
| 24 | } | |
| 25 | void Move() | |
| 26 | {
| |
| 27 | //Użyjemy tu teraz tylko i wyłącznie Vertical1, każdy gracz będzie grał jednym układem | |
| 28 | float y = Input.GetAxisRaw("Vertical1");
| |
| 29 | float speedDir = y * speed * Time.deltaTime; | |
| 30 | transform.position += new Vector3(0, speedDir, 0); | |
| 31 | } | |
| 32 | } | |
| 33 |