Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Photon.Pun;
- using UnityEngine;
- using UnityEngine.UI;
- public class Player : MonoBehaviourPun, IPunObservable
- {
- [SerializeField] float speed = 100f;
- [SerializeField] float jumpeSpeed = 800f;
- [SerializeField] GameObject cam;
- [SerializeField] Text nameText;
- int actorNumber;
- void IPunObservable.OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
- {
- }
- public void SetUp(int actorNumber, string name, bool fromSceneLoad)
- {
- Debug.Log(gameObject.name + " is local: " + photonView.IsMine);
- if (!photonView.IsMine && fromSceneLoad)
- Destroy(gameObject);
- if (photonView.IsMine)
- GetComponent<SpriteRenderer>().color = Color.green;
- this.actorNumber = actorNumber;
- nameText.text = name;
- if (photonView.IsMine)
- GameManager.getInstance.UpdateSceneCam(false);
- gameObject.name = name;
- }
- void Update()
- {
- if (photonView.IsMine)
- checkInput();
- }
- void checkInput()
- {
- Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0);
- transform.position += movement * speed * Time.deltaTime;
- }
- public int getActorNumber() { return actorNumber; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement