A
A
Alexander Pianov2020-01-19 19:19:25
C++ / C#
Alexander Pianov, 2020-01-19 19:19:25

How to cast int to object[]?

PUN2 uses object[] to pass a value to the created prefab (see data in Instantiate). This is how I try to pass the command number to the unit prefab:

object[] data = new object[2];
void Push(object o) { data[myTeam++] = o; }

Avatar = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "Avatar0"),
                    GameSetUp.GS.spawnPoints[1].position,
                    GameSetUp.GS.spawnPoints[1].rotation, 0, data);

On the created instance, there is a script with a receiving method:
public void OnPhotonInstantiate(PhotonMessageInfo info)
    {
        object[] instantiationData = info.photonView.InstantiationData;
        objects = instantiationData;
    }

But the data is not transferred. Any suggestions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Levitsky, 2020-01-21
@Lyova5

Is there an example of calling Push(object o)? The code that is written above does not fill in data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question