Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private PhotonView PV;
- public float movementSpeed;
- private float rotationSpeed = 400;
- private Joystick joystick;
- private Rigidbody rb;
- void Start ()
- {
- PV = GetComponent<PhotonView>();
- joystick = TempData.Instance.GetJoystick();
- rb = GetComponent<Rigidbody>();
- }
- void Update () {
- if (PV.IsMine)
- {
- Move();
- }
- }
- public void Move()
- {
- if (joystick.Vertical != 0 && joystick.Horizontal != 0)
- {
- transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(new Vector3(joystick.Horizontal, 0f, joystick.Vertical)),
- rotationSpeed * Time.deltaTime);
- rb.velocity = new Vector3(joystick.Horizontal * movementSpeed, rb.velocity.y,
- joystick.Vertical * movementSpeed);
- }
- }
- public void Throw()
- {
- PV.RPC("RPC_Throw", RpcTarget.All);
- }
- [PunRPC]
- private void RPC_Throw()
- {
- PhotonNetwork.Instantiate(Path.Combine("Prefabs", "Item"), transform.position,
- transform.rotation, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement