Utworznie prefaba w photonie

0

Ucze sie photona i mam problem z utworzeniem prefaba. Po wejsciu do pokoju i kliknieciu start przechodze na nowa scene. No i wtedy program sie wysypuje. Prefaba mialem na poczatku w innym folderze potem go znow przenioslem do innego by sie pozbyc problemu ale nie idzie.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using System.Security.Cryptography;
using System.Diagnostics;
using System;
using Random = UnityEngine.Random;
//using Player = Photon.Realtime.Player;

public class PlayerSpawner : MonoBehaviourPun
{
    public GameObject playerPrefab;
    public Transform[] spawnPoints;


    private void Start()
    {
        int randomNumber = Random.Range(0, spawnPoints.Length);
        Transform spawnPoint = spawnPoints[randomNumber];        
        // PhotonNetwork.Instantiate(playerToSpawn.name,spawnPoint.position,Quaternion.identity);
        PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
    }

}

Dostaje cos takiego

DefaultPool failed to load "player". Make sure it's in a "Resources" folder. Or use a custom IPunPrefabPool.
UnityEngine.Debug:LogError (object)

NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.DefaultPool.Instantiate (System.String prefabId, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at Assets/Photon/PhotonUnityNetworking/Code/PunClasses.cs:884

0

A w jakim folderze teraz trzymasz? Wg tej wiadomości powinien leżeć w folderze Resources. Dodatkowo możesz w inspektorze przeciągnąć go na tym spawnerze, do pola playerPrefab

0

Mialem na poczatku bez katalogu potem dalem w ten katalog resource i dalej jest blad. Prefab jest przeciągnięty do skryptu .

1 użytkowników online, w tym zalogowanych: 0, gości: 1