Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Unity Multiplayer Photon Pun

Discussion in 'General Discussion' started by Cedric2412, Nov 1, 2022.

Thread Status:
Not open for further replies.
  1. Cedric2412

    Cedric2412

    Joined:
    Apr 26, 2021
    Posts:
    2
    Hi,
    we have a problem with our controls. The Player should be controlled by using the buttons.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Photon.Pun;
    5.  
    6.  
    7. public class Player : MonoBehaviourPunCallbacks
    8. {
    9.     public PhotonView view;
    10.     public Rigidbody2D rb;
    11.     public GameObject Players;
    12.     public bool Left;
    13.     public bool Right;
    14.     public bool Up;
    15.     public bool Down;
    16.     public GameObject Bow;
    17.     private int MausPos;
    18.     public int PlayerAnzahl;
    19.     void Start()
    20.     {
    21.         rb = GetComponent<Rigidbody2D> ();
    22.         view = GetComponent<PhotonView> ();
    23.         Players.GetComponent<PlayerAnzahl>().HowMuchPlayer++;
    24.         Right = false;
    25.         Up = false;
    26.         Down = false;
    27.         Left = false;
    28.     }
    29.     public void Left1()
    30.     {
    31.         if(view.IsMine)
    32.         {
    33.         Left = true;
    34.         Bow.GetComponent<Bow>().Answer = true;
    35.             if (Players.GetComponent<PlayerAnzahl>().possible == true)
    36.             {
    37.                 rb.AddForce (Vector3.left * 0.0001f);
    38.                 transform.eulerAngles = new Vector3(0, 180, 0);
    39.             }
    40.         }
    41.     }
    The button activates Left1().

    Thanks for help.
     
  2. Cedric2412

    Cedric2412

    Joined:
    Apr 26, 2021
    Posts:
    2
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    9,404
    The general discussion forum, as its description states, is not a support forum.
     
Thread Status:
Not open for further replies.