#im following a multiplayer tutorial and

1 messages Β· Page 1 of 1 (latest)

tender moon
#

Do you still have the same error after correcting isMine to IsMine ?

minor hatch
#

noi

#

lemme ashafre the script

tender moon
#

!code

severe pelicanBOT
#
Posting code

πŸ“ƒ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

πŸ“ƒ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

minor hatch
#

sorry

tender moon
#

Try following these guidelines to make it more readable for us pls πŸ™‚

tender moon
minor hatch
#

whats a back quote

#

`

#

?

tender moon
#

Yup `

minor hatch
#

idk how it works

tender moon
#

otherwise use something like hastebin and whre us the link πŸ™‚

#

Perfect

minor hatch
#

can u please dm me ive got to go

#

for a game of golf

tender moon
#

This thread will be open when you'll come back if you wanna continue this

minor hatch
#

ok

#

thankyou!

tender moon
#

Np

minor hatch
#

im back!

#

@tender moon soryr for ping

tender moon
#

So what was your problem apart from the error ?

minor hatch
#

the script is meant to let u8 control the player u spawned in and that player only. instead, mit freezes on eplayer and lets u control the other player

#

and both people can control it

#

so your player is frozen and the other player is the one u control

tender moon
#

I'm not an expert with Photon unfortunately, but i'll try to help. What is handling your players spawn ?

minor hatch
#

a script

tender moon
#

Can you show me this script ?

minor hatch
#

it randomly spawns the player between a set of co-ordinates

tender moon
#

OK. And what script handles the camera controls ?

#

It's included in character controller ?

minor hatch
#

as in the turning or the cursor lock?

tender moon
minor hatch
tender moon
#

I think the problem isn't that you're controlling the wrong character, but that you have the wrong view

minor hatch
#

how do i fix that?

tender moon
#

Are the PlayerMovement and MouseLook attached to the same gameobject ?

minor hatch
#

no

#

actually idk

#

no

tender moon
#

OK, it's fine, it was just so I know how your script are "placed"

minor hatch
#

mosue look is in main camera

tender moon
#

In PlayerMovement, add a field to store a ref to the camera in the prefab.

minor hatch
#

how

tender moon
#

[SerializedField] private Camera camera;

minor hatch
#

where

#

anywhere in the script?

tender moon
#

You can put it under public CharacterController controller;

minor hatch
tender moon
#

remove the d, it's SerializeField. My bad.

minor hatch
#

done

tender moon
#

and rename camera to playerCamera or the debugger will put a warning I suppose

minor hatch
#

ok imma test!

#

nope

#

u still controll the other player

tender moon
#

Ok, then we'll do 2 modifications:

  • put view = GetComponent<PhotonView>(); in Awake instead of Start
  • in Start, do this
if(!view.IsMine)
{
  playerCamera.enable = false;
}
minor hatch
#

whats awake?

tender moon
#

Another Unity method like Start, or Update that is called when the object is loaded.

#

It's better to initialize references in Awake before using them in Start.

minor hatch
#

so where do i put it?

tender moon
#
{
  // do some stuff here
}
minor hatch
#

ok

tender moon
#

you can put it above Start

minor hatch
#

like so?

#

ok

#

new error

tender moon
#

rename your camera variable into playerCamera

minor hatch
#

this?

tender moon
#

yep

#

You might have skipped my message where I said camera might collide with an already existing one

minor hatch
#

like this?

#

cus theres an error]

tender moon
#

line 33, it's enabled no enable

#

I misstype a lot today, sorry

minor hatch
#

what should it be?

#

ok

#

aight im gonna test

tender moon
#

make sure you told what camera to use in your player inspector

minor hatch
#

yep

#

it works!

tender moon
#

Great πŸ™‚

minor hatch
#

thankyou Kaihyo

#

youv'e been extremely helpful considering u were no good using Photon!

tender moon
#

It might not be the best way to do it tho', so for better insight on networking code, check #archived-networking. They'll be of better help once you'll have more advance topics ^^

minor hatch
#

ok thanks

#

not to do withg this thread but how do i play this game with my friends because the build is a unity file

tender moon
#

Hmm, you'd need to build your project so that you have a proper build folder (with data and an .exe file), and share it with them

minor hatch
#

any idea how?@

tender moon
minor hatch
#

doesnt explain much lol

tender moon
#

Let me a second, I'll try to find the beginner course that explains it

minor hatch
#

thanks

tender moon
minor hatch
#

thanks mill watch the video

tender moon
#

Np, have a nice day πŸ™‚

minor hatch
#

so essentially i just send my friends th edata?