Adehm

C# Unity Photon C# basics

Recommended Posts

 

I was wondering if anyone knew how to simply send and receive an integer?

if (PhotonNetwork.isMasterClient) {

//send an integer

}

If(!PhotonNetwork.isMasterClient){

//receive integer

}

 

Share this post


Link to post
Share on other sites

Yeah I can’t get it to work. Was hoping someone would be able to get me a simple example of either making a stream or just adding to a stream before its sent and receiving it. Tried several different ways and can’t get anything to work even in the rare cases that I can write what I’m told without error it just wont do anything.

Edited by Adehm

Share this post


Link to post
Share on other sites

I haven't used Photon in a couple years but did you take a look at the demo (vikings IIRC) that comes with the package? IIRC that contained everything I needed to get it off the ground.

Share this post


Link to post
Share on other sites

Thanks a bunch cmac you lead me to the solution. This video explains it wonderfully for anyone else who would like to know how to add data to the stream.

Kinda weird how you have to drag the script from a component to make it observable; didn't find a way to just do it manually through the control as it only allows me to select a gameobject and by default it's transform.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Announcements

  • Forum Statistics

    • Total Topics
      628362
    • Total Posts
      2982266
  • Similar Content

    • By Jim Bachalo
      Hi
      Having a huge problem trying to simply implement a working framework for a turn based (each player takes turns) board game using UNET (Unity).
      I have an Eventmanager system I am comfortable with for sending, receiving custom events.
      I want to avoid adding any unnecessary complexity, so no State machine etc.
      Just a Model class
      A Game Controller
      Perhaps a controller for each player?
      And a View for the board and game pieces.

      Not sure whether most of the game logic (calculating score, wins etc.) would go in the Game Controller or Model class.
      Will extend this for use in AR.

      Can anyone help?
      Are there any really useful MVC C# templates that would get me started?
      Any help appreciated!
    • By idzohar
      I am trying to rotate my car sprite just slightly to the left or right depending on input up to a small maximum. When I use this code, the rotation doesn't stop at the maximum i give it. When i try to reset the rotation back to its original state when not pressing any input, the car also jitters between a z axis rotation of 0 and 2.5. I don't understand why the rotation doesn't stop at the given maximums, nor do I understand why its jittering. Can anybody provide me some insight?
              float movementHorizontal = 0f;
              float movementVertical = 0f;
              if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
              {
              }
              else if (Input.GetKey(KeyCode.A))
              {
                  movementHorizontal = -1;
                  if (transform.rotation.z < 10f)
                  {
                      transform.Rotate(zAxis, 2.5f);
                  }            
              }
              else if (Input.GetKey(KeyCode.D))
              {
                  movementHorizontal = 1;
                  if (transform.rotation.z > -10f)
                  {
                      transform.Rotate(zAxis, -2.5f);
                  }
                  
              }
              else
              {
                  if(transform.rotation.z > 0)
                  {
                      transform.Rotate(zAxis, -2.5f);
                      //transform.rotation.Set(0, 0, 0, 0);
                  }
                  else if (transform.rotation.z < 0)
                  {
                      transform.Rotate(zAxis, 2.5f);
                      //transform.rotation.Set(0, 0, 0, 0);
                  }
                  
              }
    • By Madolite
      (Note to Mods: Could "Input" or "Peripherals" be a good Tag to add to the tag list? Just a thought.)

      Hey, I'm currently working on which keys on a keyboard that a user can rebind their actions to. The trick is that I use a Norwegian keyboard, so it's not obvious which keys correspond to the actual C#/XNA Keys enum values.

      Are there any keys from the XNA Keys enum that, in your opinion, I've neglected to add? I don't need all Keys to be bindable, only the "most commonly used keys on a keyboard". Thanks.
      https://pastebin.com/n1cz8Y0u
    • By Eck
      I just saw their courses were knocked down to $10 each and figured I'd share the info here. They have stuff for Unity, Unreal, drawing, business, etc. I haven't used their stuff before, but the previews I looked at seemed pretty good and there is a user review system as well.
      https://www.udemy.com/courses/search/?q=Unity&src=ukw
      - Eck
       
    • By sidbhati32
      I am working on a game in which we control a rectangular box at the bottom of the screen. Three sphere which has alphabets in it fall down. When the game starts, a word is generated from the predefined list of words(which I'll give) and we are supposed to touch the correct sphere having the alphabet based on that word. The question is how to detect if I have touched the correct sphere. 
      secondly, if I have touched a correct sphere before and there is no recurrence of that alphabet in that word then during the second wave the game should not proceed if I touch the same alphabet again.
      Looking forward to your answers, i have to submit this project in a couple of days. please help! (Working on Unity 3D)
      Thanks
  • Popular Now