El juego del Calamar photon conexiones y posiciones

Aquí lo que vamos hacer es hacer un limite de jugadores en nuestro partida, y colocar nuestros jugadores en determinadas posiciones ahora mismo con el post anterior . AQUI….

Podemos entrar en la habitación tantos jugadores como nosotros queramos, así lo que vamos hacer vamos air a la escena 1 donde tenemos nuestro menu

ahora vamos a editar nuestro script , incorporar lo siguiente a nuestro script

con este script, pondríamos máximo dos jugadores y ambos se conectarían a la vez
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; using UnityEngine.SceneManagement; public class MANAGER : MonoBehaviourPunCallbacks { public InputField creartext; public InputField Jointtext; public const int maxPlayerPerRoom = 2; void Start() { PhotonNetwork.ConnectUsingSettings(); PhotonNetwork.AutomaticallySyncScene = true; } public override void OnConnectedToMaster() { PhotonNetwork.JoinLobby(); } // Start is called before the first frame update public void CreateRomm() { PhotonNetwork.CreateRoom(creartext.text); } public override void OnJoinRandomFailed(short returnCode, string message) { PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = maxPlayerPerRoom }, null); } public void JoinRomm() { PhotonNetwork.JoinRoom(Jointtext.text); } public override void OnPlayerEnteredRoom(Player newPlayer) { PhotonNetwork.CurrentRoom.IsOpen = false; Debug.Log(«Ya estanos todos»); PhotonNetwork.LoadLevel(«Game»); } }

Ahora vamos a la escena donde comenzara nuestro juego vamos a establecer las pocisiones

Vamos a nuestro script

Lo vamos a borrar y vamos a incorporar el siguiente
y ponemos este script con este script llamaríamos a nuestros personajes, ahora solo queda poner en que lugar salen nuestros personajes
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using UnityEngine.SceneManagement; public class ConecteServer : MonoBehaviourPunCallbacks { public Transform spaPoint01, spaPoint02; private void Awake() { if (PhotonNetwork.IsMasterClient) { PhotonNetwork.Instantiate(«PLAYER», spaPoint01.position, spaPoint01.rotation); } else { PhotonNetwork.Instantiate(«PLAYER02», spaPoint02.position, spaPoint02.rotation); } } }

Ahora os pondré el Script del personaje, pero no es el que utilizaremos para nuestro juego

using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; public class ci : MonoBehaviourPunCallbacks { public float speed; private Rigidbody2D rb; private Vector2 moveVelocity; // Start is called before the first frame update void Start() { rb = GetComponent(); } // Update is called once per frame void Update() { PhotonNetwork.AutomaticallySyncScene = false; if (photonView.IsMine) { ProcessInputs(); } } private void ProcessInputs() { Vector2 moveInput = new Vector2(Input.GetAxisRaw(«Horizontal»), Input.GetAxisRaw(«Vertical»)); moveVelocity = moveInput.normalized * speed; } void FixedUpdate() { rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime); } }
  • Related Posts

    Messi hizo un Mundial increíble con 39 años, pero para mí no merece el Balón de Oro 2026.

    Messi y el Balón de Oro 2026 un Mundial increíble a los 39 años, pero para mí no es suficiente Hablar de Lionel Messi y el Balón de Oro, creo…

    Mourinho ha vuelto, pero el Real Madrid no: muchas estrellas, demasiado ego y muy poco equipo

    Mourinho y su segunda etapa en el Real Madrid: tengo muchas dudas La segunda etapa de Mourinho en el Real Madrid me genera muchas dudas. Yo soy de esas personas…

    Deja una respuesta

    You Missed

    Messi hizo un Mundial increíble con 39 años, pero para mí no merece el Balón de Oro 2026.

    • Por admin
    • septiembre 29, 2026
    • 5 views
    Messi hizo un Mundial increíble con 39 años, pero para mí no merece el Balón de Oro 2026.

    Mourinho ha vuelto, pero el Real Madrid no: muchas estrellas, demasiado ego y muy poco equipo

    • Por admin
    • septiembre 26, 2026
    • 13 views
    Mourinho ha vuelto, pero el Real Madrid no: muchas estrellas, demasiado ego y muy poco equipo

    Lamine vs Kane: ganar el Mundial no significa haber sido el mejor

    • Por admin
    • septiembre 26, 2026
    • 22 views
    Lamine vs Kane: ganar el Mundial no significa haber sido el mejor

    Sí, quéjate del árbitro… pero primero juega al fútbol, el problema del Real Madrid va más allá del VAR.

    • Por admin
    • septiembre 22, 2026
    • 24 views
    Sí, quéjate del árbitro… pero primero juega al fútbol, el problema del Real Madrid va más allá del VAR.

    Raphinha tira del Barça, Lamine se lleva las portadas: ¿rendimiento o marketing?

    • Por admin
    • septiembre 20, 2026
    • 49 views
    Raphinha tira del Barça, Lamine se lleva las portadas: ¿rendimiento o marketing?

    Del Messi-Cristiano al “yo merezco el Balón de Oro”: ¿en qué momento cambió tanto el fútbol?

    • Por admin
    • septiembre 19, 2026
    • 39 views
    Del Messi-Cristiano al “yo merezco el Balón de Oro”: ¿en qué momento cambió tanto el fútbol?