How i do reverse movement for 2nd player
Options
i have bad english sorry about that
i have 2 player in my game and 2 player spawning in same position but i want reverse movement for 2nd player, i can give an example: like clash royale
2 player starting on bottom but player see the enemy on the top, how can i do that
there is my script:
i hope someone give help to me
i have 2 player in my game and 2 player spawning in same position but i want reverse movement for 2nd player, i can give an example: like clash royale
2 player starting on bottom but player see the enemy on the top, how can i do that
there is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using System; public class Movement : MonoBehaviour , IPunObservable { public float hareketHızı; Rigidbody2D rb; PhotonView pht; public GameObject rakip; void Start() { pht = GetComponent<PhotonView>(); if (pht.IsMine) { rb = GetComponent<Rigidbody2D>(); } GameObject[] players = GameObject.FindGameObjectsWithTag("Oyuncu"); for(int i=0; i < players.Length-1; i++) { PhotonView oyuncuPht = players[i].GetComponent<PhotonView>(); if (oyuncuPht.IsMine) { int x = i; if (x == 0) { Debug.Log(players[0].name); oyuncuPht.RPC("setRakip", RpcTarget.AllBuffered, players[1].name); Debug.Log(players[1].name); } } } } [PunRPC] void setRakip(string name ) { rakip = GameObject.Find(name); } void Update() { if (pht.IsMine) { float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); rb.velocity = new Vector2(x * hareketHızı, y * hareketHızı); } } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { if (rakip != null) { stream.SendNext(-rakip.transform.position); } }else { if (rakip != null) { rakip.transform.position = (Vector3)stream.ReceiveNext(); } } } }sorry my english again
i hope someone give help to me
0
Answers
-
Guys i solved my problem, i instantiated players to 3.54 and -3.54
and also if myPlayer in 3.54, i rotated my camera's z rotation to 180 and i changed my walk script to this angle and i solved my problem the topic can be lockdown0