Update()
{
if(какое то условие)
{
Right();
}
else if(какое то условие)
{
Left();
}
MoveForward();
}
public void MoveForward()
{
transform.position += transform.up * speed;
}
public void Right()
{
transform.Rotate(Vector3.forward * rotatePower);
}
public void Left()
{
transform.Rotate(Vector3.back * rotatePower);
}
Update()
{
if(какое то условие)
{
Right();
}
else if(какое то условие)
{
Left();
}
MoveForward();
}
if (rightMove)
{
if (transform.rotation.z < limitHigh) //90
{
print("limitHigh");
transform.Rotate(move * -speed);
}
else
{
rightMove = false;
}
}
else
{
if (transform.rotation.z > limitLower) //-90
{
print("limitHigh");
transform.Rotate(move * speed);
}
else
{
rightMove = true;
}
}
using Photon.Pun;
using UnityEngine.UI;
using Photon.Realtime;
public class MenuManager : MonoBehaviourPunCallbacks
{
public InputField createInput;
public InputField joinInput;
public void createRoom()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 6;
PhotonNetwork.CreateRoom(createInput.text, roomOptions);
}
public void joinRoom()
{
PhotonNetwork.JoinRoom(joinInput.text);
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("Game");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using Photon.Pun;
public class ConnectToServer : MonoBehaviourPunCallbacks
{
void Start()
{
PhotonNetwork.ConnectUsingSettings();
}
public override void OnConnectedToMaster()
{
SceneManager.LoadScene("Menu");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class PlayersSpawn : MonoBehaviourPunCallbacks
{
public GameObject playerPrefab;
public Transform[] spawnpoints;
public void Spawn()
{
PhotonNetwork.Instantiate(playerPrefab.name, spawnpoints[Random.Range(0, spawnpoints.Length)].position, Quaternion.identity);
}
}
Can not Instantiate before the client joined/created a room. State: PeerCreated
UnityEngine.Debug:LogError(Object)
Photon.Pun.PhotonNetwork:Instantiate(String, Vector3, Quaternion, Byte, Object[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2477)
PlayersSpawn:Spawn() (at Assets/Scripts/PlayersSpawn.cs:13)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.3.12f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
using Photon.Pun;
using UnityEngine;
using UnityEngine.UI;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
public class MenuManager : MonoBehaviourPunCallbacks
{
public InputField createInput;
public InputField joinInput;
public void createRoom()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 6;
PhotonNetwork.CreateRoom(createInput.text, roomOptions);
}
public void joinRoom()
{
PhotonNetwork.JoinRoom(joinInput.text);
}
public override void OnJoinedRoom()
{
PhotonNetwork.LoadLevel("Game");
}
}
Потому что по моей логики должно быть что то типо:
если (поворот при методе lookAt(игрок) < поворота по z сейчас)
{
повернуть в право();
}
если (поворот при методе lookAt(игрок) > поворота по z сейчас)
{
повернуть в право();
}
Что то типо такого?