#im following a multiplayer tutorial and
1 messages Β· Page 1 of 1 (latest)
!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.
sorry
Try following these guidelines to make it more readable for us pls π
Don't worry, it's alright
Yup `
idk how it works
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
This thread will be open when you'll come back if you wanna continue this
Np
So what was your problem apart from the error ?
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
this should help
so your player is frozen and the other player is the one u control
I'm not an expert with Photon unfortunately, but i'll try to help. What is handling your players spawn ?
a script
Can you show me this script ?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
it randomly spawns the player between a set of co-ordinates
OK. And what script handles the camera controls ?
It's included in character controller ?
as in the turning or the cursor lock?
moving the camera around, it looks like you can do this from your character even if you can't move it around
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
I think the problem isn't that you're controlling the wrong character, but that you have the wrong view
how do i fix that?
Are the PlayerMovement and MouseLook attached to the same gameobject ?
OK, it's fine, it was just so I know how your script are "placed"
In PlayerMovement, add a field to store a ref to the camera in the prefab.
how
[SerializedField] private Camera camera;
You can put it under public CharacterController controller;
remove the d, it's SerializeField. My bad.
done
and rename camera to playerCamera or the debugger will put a warning I suppose
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;
}
whats awake?
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.
so where do i put it?
{
// do some stuff here
}
ok
you can put it above Start
rename your camera variable into playerCamera
yep
You might have skipped my message where I said camera might collide with an already existing one
make sure you told what camera to use in your player inspector
Great π
thankyou Kaihyo
youv'e been extremely helpful considering u were no good using Photon!
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 ^^
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
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
any idea how?@
doesnt explain much lol
Let me a second, I'll try to find the beginner course that explains it
thanks
Hope this will be better https://learn.unity.com/tutorial/publishing-for-pc-mac
thanks mill watch the video
Np, have a nice day π
so essentially i just send my friends th edata?