Unity Multiplayer Tutorial using Mirror [ABANDONED]

Sdílet
Vložit
  • čas přidán 5. 08. 2024
  • I'VE ABANDONED THIS SERIES AS I DON'T USE UNITY ANYMORE. AN UNREAL ENGINE VERSION OF THIS TUTORIAL WILL BE RELEASED SOON.
    Welcome to my video series on how to make a multiplayer game with Unity using Mirror
    Join The Discord : / discord
    PlayerController Script : ghostbin.co/paste/herv9
    If you like this, please check out some of my other videos. Thanks for watching!
  • Věda a technologie

Komentáře • 215

  • @ikizlerlebirgun7119
    @ikizlerlebirgun7119 Před 3 lety +43

    I saw photon, i looked at a comment about mirror. I searched mirror and saw that my favourite channel already made a tutorial 28 minutes ago. Thats a miracle.

    • @zyapguy
      @zyapguy  Před 3 lety +7

      Thank you :)

    • @alooyeg
      @alooyeg Před 3 lety +2

      a miracle? that magic

    • @naokimc
      @naokimc Před 2 lety +2

      I saw mirror, I looked at a comment about photon, and want zyapguy to make a vid :)
      and this is da comment

    • @pogchamp1081
      @pogchamp1081 Před 2 lety

      Same

  • @nullpro7435
    @nullpro7435 Před 2 lety +21

    Multiplayer using mirror
    Step 1. Get mirror, use Amazon because honestly you’re not gonna leave you’re home
    Step 2. Hang mirror on wall
    Step 3. Go insane (30 minutes of debugging C in text edit with no google should do this (or 30 seconds of JavaScript)
    Step 4. Stand in front of a mirror and hallucinate that you’re reflection comes alive
    Step 5. Multiplayer!

  • @natethedub
    @natethedub Před 2 lety +4

    Great vid man. Helped me a lot. Can’t wait to see this tutorial continued!

  • @b9boy
    @b9boy Před 2 lety +9

    bro this is the only unity mirror tutorial i resonated with. really bummed me out when i saw that this was the only tutorial you made though :(

  • @spook2387
    @spook2387 Před 3 lety +31

    I came to this channel for the "types of programmers" kind of video, didn't expect any tutorials, but ngl this is a pretty good one.
    Good job!

    • @zyapguy
      @zyapguy  Před 3 lety +8

      The problem is, I don't want to keep making the same type of video. Also, someone asked me to make a multiplayer tutorial so I decided why not. But worry not! I will still make types of videos :D

    • @spook2387
      @spook2387 Před 3 lety +5

      @@zyapguy Understandable, like your videos either way

    • @zyapguy
      @zyapguy  Před 3 lety +4

      @@spook2387 Thank you :D

    • @fitmotheyap
      @fitmotheyap Před 2 lety

      @@zyapguy soooo ep 2 when lmao

    • @amongsus3233
      @amongsus3233 Před 2 lety

      @@zyapguy will you continue this ? please

  • @tukang3d
    @tukang3d Před 2 lety +1

    Hey man, this video is wayyy wayyy way more valuable to me to learn Mirror. Huge thumbs to you!

  • @maxit0x
    @maxit0x Před rokem

    Clear tutoria! Awesome! Thanks! I hope you keep with the good content my friend!

  • @Jameel_Ali
    @Jameel_Ali Před 3 lety +5

    Bro, this gonna be really good

  • @rockerguy9683
    @rockerguy9683 Před 2 lety +1

    Great intro video! Hoping you're going to continue the series soon!

  • @hjtomi_
    @hjtomi_ Před 3 lety +4

    Good to see fresh Unity tutorials!

    • @zyapguy
      @zyapguy  Před 3 lety +5

      When I was learning Mirror, there was like only 2 tutorials and one of them didn't even work. Wanted to help the community out :D

    • @FriedMonkey362
      @FriedMonkey362 Před 3 lety +1

      @@zyapguy playercontrolerscript pastebin link does not work anymore

  • @OrigamiDunyas
    @OrigamiDunyas Před 2 lety +105

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    [RequireComponent(typeof(CharacterController))]
    public class PlayerController: MonoBehaviour
    {
    public float walkingSpeed = 7.5f;
    public float runningSpeed = 11.5f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;
    public Camera playerCamera;
    public float lookSpeed = 2.0f;
    public float lookXLimit = 45.0f;
    CharacterController characterController;
    Vector3 moveDirection = Vector3.zero;
    float rotationX = 0;
    [HideInInspector]
    public bool canMove = true;
    void Start()
    {
    characterController = GetComponent();
    // Lock cursor
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }
    void Update()
    {
    // We are grounded, so recalculate move direction based on axes
    Vector3 forward = transform.TransformDirection(Vector3.forward);
    Vector3 right = transform.TransformDirection(Vector3.right);
    // Press Left Shift to run
    bool isRunning = Input.GetKey(KeyCode.LeftShift);
    float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
    float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
    float movementDirectionY = moveDirection.y;
    moveDirection = (forward * curSpeedX) + (right * curSpeedY);
    if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
    {
    moveDirection.y = jumpSpeed;
    }
    else
    {
    moveDirection.y = movementDirectionY;
    }
    // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
    // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
    // as an acceleration (ms^-2)
    if (!characterController.isGrounded)
    {
    moveDirection.y -= gravity * Time.deltaTime;
    }
    // Move the controller
    characterController.Move(moveDirection * Time.deltaTime);
    // Player and Camera rotation
    if (canMove)
    {
    rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
    rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
    playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
    transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
    }
    }
    }

  • @matthew12438
    @matthew12438 Před 2 lety

    I’m pretty new to unity especially multiplayer, this will help a lot. Thx

  • @kratosgodofwar777
    @kratosgodofwar777 Před 3 lety +2

    This is really cool! I always wanted to learn something about game development.
    Also *types of unity developers* when?

  • @geco3335
    @geco3335 Před 3 lety +3

    Happy to see new types of video 👍👍

  • @aliezzaym1735
    @aliezzaym1735 Před 3 lety +1

    thank you this video was realy useful, you deserve more subs

  • @idiotguyREAL
    @idiotguyREAL Před rokem

    Thank you so much! I was stuck on mirror for so long

  • @jenycek2222
    @jenycek2222 Před 3 lety +17

    You are slowly (but surely) becoming an Indian guy on CZcams...

    • @vitalityedge9406
      @vitalityedge9406 Před 3 lety

      no shit

    • @tukang3d
      @tukang3d Před 2 lety

      Why Indian guy? Can't understand it... he is Russian I think and this video is sooooooo good.

    • @jenycek2222
      @jenycek2222 Před 2 lety +1

      @@tukang3d There is a saying circulating between all programmers (now including you) that has been present since the beginning of the programmer era and goes like this: "If you can't find it on StackOverflow, there must be an Indian guy on CZcams explaining it to you in one of his videos".

    • @jenycek2222
      @jenycek2222 Před 2 lety

      take it as a joke (because you are able to find almost everything on StackOverflow these days), but if you ever encounter a computer problem, you can pretty much be sure, that some Indian CZcams channel explains it.

    • @tukang3d
      @tukang3d Před 2 lety

      @@jenycek2222 yeap agree.. hmm.. but I mostly hate Indian channel especially when I see the video title in English but when I play the video he talks Hindi. Dang it.

  • @karthiknivedhan8622
    @karthiknivedhan8622 Před 3 lety +1

    This is the best tutorial on mirror in youtube

  • @petrov2717
    @petrov2717 Před rokem

    This was a very good tutorial. Good job 👍

  • @xDDBF
    @xDDBF Před 2 lety +4

    Gotta love youtubers doing "part 1" of something and not continuing the work.

  • @af57458
    @af57458 Před 2 měsíci +1

    MAN , YOU ARE THE BEST , I COULDN’T FOUND HOW FIX A CAMERA’S PROBLEM . AND I FINALLY I FOUND , MY MASTER TO FIX IT 😅

  • @poi7119
    @poi7119 Před 2 lety

    Thank you. I'm Korean but this video was so good that I could understand all of things.

  • @GameBob
    @GameBob Před 4 měsíci

    It's important to note that you CAN have 2 cameras active at the same time :) I use 4 for my project at all times. It will make 1/the most recently turned-on camera for the main projection. You can change which one is used in the code or by enabling/disabling. You can also use a secondary camera for a MiniMap or as a second screen if you want a second monitor screen activated. Oddly enough it is very handy to have that as an option. I highly recommend trying out secondary or more monitor options for games as it could make a game that much more customizable for those with the tech/want. I'm a huge fan of having as many options as I could get. Think observation duty but you could monitor 2 ROOMS AT ONCE!!! Now that sounds like a really interesting effect. Just wish it would work better for streamers/CZcamsrs. I'm still trying to figure that part out lol.

  • @sarahkline5037
    @sarahkline5037 Před 2 lety +2

    Please continue the series!

  • @L3RNA3AN
    @L3RNA3AN Před 2 lety

    This is helpful. Thanks a million!

  • @ilushkinz4424
    @ilushkinz4424 Před 3 lety +2

    U lucky boy, youtube recommended you to me. Not a big fan of mirror, I like use litenetlib + custom netcode, but nice vid, wish you luck with your tutorial series

  • @_minke
    @_minke Před 10 měsíci

    your video is awesome, please continue the part

  • @mikenovion
    @mikenovion Před rokem

    Great tutorial! Keep going!

  • @ErenBR562
    @ErenBR562 Před 2 lety

    Hello, I'm creating an FPS camera and using the FirstPersonController script from Unity's StandardAssets, it works almost perfectly, however, do you know why when I activate the vertical mouse clamp, on mobile it keeps giving a nan nan nan problem on the camera? When I disable the clamp, the error disappears, however, the clamp is gone. Thank you!

  • @Quiqqy
    @Quiqqy Před 2 lety +1

    you handled both my errors! new sub for you!

  • @arkandash5895
    @arkandash5895 Před 3 lety +3

    Lol, I thought you only make a programmer meme or somewhat, but actually more helping me make a multiplayer game, Thank god, that I subscribe to your channel. I actually didn't understand about it

  • @malavidra
    @malavidra Před 2 lety

    Great tutorial man :)

  • @dearedcochico8379
    @dearedcochico8379 Před 2 lety

    thanks, you've earned new subscriber :)

  • @Kasuga-
    @Kasuga- Před rokem +1

    Continue this series!!

  • @BluePhantomGames
    @BluePhantomGames Před 2 lety +3

    First of all I don't recommend connection with IP address so i would suggest 2 things. First, mirror has a room manager transport so, check out the documentation about this transport.
    Second, Mirror suggests to checkout there unity demo scene about that transport to learn about it.

  • @lora6938
    @lora6938 Před rokem

    HELLO! As I understand it, the mirror is only for a local connection? Have you tried connecting to other computers?

  • @absolutestrange
    @absolutestrange Před 3 lety +1

    The link in description for the code is not working for some reason, is it just me?

  • @Ahsan-Ahmed
    @Ahsan-Ahmed Před 3 lety

    Actual tutorial yeah boi

  • @parsydev
    @parsydev Před 2 lety +1

    Is this online or only LAN? I dont want to buy a Server ho can i make that the player hosts a server, i mean peer to peer

  • @vsvrp1995
    @vsvrp1995 Před 2 lety +2

    Please make more videos on Unity Multiplayer with Mirror.. Please
    Thanks in advance... And I Subscribed. :)

  • @huudungnguyen5453
    @huudungnguyen5453 Před 2 lety

    very useful for me. tks a lot

  • @lokeshgoyal1208
    @lokeshgoyal1208 Před rokem

    Assets\Mirror\Runtime\NetworkReaderExtensions.cs(157,17): error CS0246: The type or namespace name 'ReadOnlySpan' could not be found (are you missing a using directive or an assembly reference?)
    I install it and got these error, any idea to fix it

  • @Serious_Im
    @Serious_Im Před rokem

    OMG You helped me so much

  • @alexandermorsjakobsen2148

    I already know how to make multiplayer games in unity. But still watched the hole video.

  • @FriedMonkey362
    @FriedMonkey362 Před 2 lety

    it does not work, once i join i can see the other instnace move thye are both singleplayer all that happens is that a capsule spawns and gets removed once the other one leaves/joines, help

  • @user-hu6jo2rg3d
    @user-hu6jo2rg3d Před rokem

    Thank you 😍😍😍 awesome 🤩🤩🤩

  • @maxsim_sw
    @maxsim_sw Před rokem +1

    There was no active transport when calling NetworkServer.Listen, If you are calling Listen manually then make sure to set 'Transport.active' first
    UnityEngine.Debug:Assert (bool,string)
    NullReferenceException: Object reference not set to an instance of an object
    how do I fix this?????????? i did the sam as shown in the video:(

  • @user-kk2il2tm1q
    @user-kk2il2tm1q Před rokem +1

    can you please make a video about how to do the same thing without "client authority" in the client "network transform" ? i've been waiting for a second tutorial in this series..

  • @antdx316
    @antdx316 Před rokem

    so IP address + open port, if the server is running on that then anyone can connect?

  • @Maxaxaax
    @Maxaxaax Před rokem

    I got an error NullReferenceException: Object reference not set to an instance of an object

  • @CasperHuik
    @CasperHuik Před rokem

    Thanks a lot

  • @insaneguy4039
    @insaneguy4039 Před 2 lety +1

    Hello. I am currently working on a multiplayer FPS game but ran into a problem. What should I do to make the player's mesh invisible to the player controlling it?

    • @scott_41
      @scott_41 Před 2 lety

      I'm sure you've sorted it by now, but if not you could disable the mesh renderer component if isLocalPlayer is true

    • @BluePhantomGames
      @BluePhantomGames Před 2 lety

      If local player disable ur player's mesh xD it's ez what's the problem

  • @3d-school
    @3d-school Před 11 měsíci

    I write the ip address of the server, but the client does not want to connect to the server what to do?

  • @deltap6045
    @deltap6045 Před 2 lety +1

    Waiting for Part 2

  • @soykankamal4248
    @soykankamal4248 Před 2 lety

    Very helpful! Pls come back to life

  • @RedBloxStudios
    @RedBloxStudios Před 2 lety

    uhh how do how does other players from internet?
    He breifs over it too much and the UI is different from his
    Help

  • @xl965
    @xl965 Před rokem +2

    Can this achieve animation synchronization?

    • @zyapguy
      @zyapguy  Před rokem

      Yes of course. In the player, add the NetworkAnimator. drag the animator that you want to sync to the empty slot and check "Client". After that, it will sync perfectly.

  • @potatoml4631
    @potatoml4631 Před 2 lety +1

    any follow up tutorials soon ?

  • @lora6938
    @lora6938 Před 2 lety

    Hello! And can you Please 🙏show how to make a connection if it's a different type of game (board game) When it's not control of a character, but moving objects with the cursor is just like any board game!

  • @joaquinfraustoalfarorocco8177

    i really just need one thing, how df do i make a debug.log from a client on another client >:,c

  • @africayean1311
    @africayean1311 Před 3 lety +3

    we found the youtuber programmer! lol

  • @sql64
    @sql64 Před 3 lety +4

    i want to be a bird

  • @MalachiRails
    @MalachiRails Před 3 lety +1

    How did I miss this

  • @WowVital
    @WowVital Před 2 lety +2

    Where is PART2?

  • @leapyear8845
    @leapyear8845 Před 3 lety +2

    Why am I watching this
    Am i like oh boy time to code on my nonexistent PC

  • @MozesRosenthal
    @MozesRosenthal Před 2 lety +1

    For Anyone Who Is getting trouble with the code in ghostbin here's it right here: using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    [RequireComponent(typeof(CharacterController))]
    public class PlayerController : MonoBehaviour
    {
    public float walkingSpeed = 7.5f;
    public float runningSpeed = 11.5f;
    public float jumpSpeed = 8.0f;
    public float gravity = 20.0f;
    public Camera playerCamera;
    public float lookSpeed = 2.0f;
    public float lookXLimit = 45.0f;
    CharacterController characterController;
    Vector3 moveDirection = Vector3.zero;
    float rotationX = 0;
    [HideInInspector]
    public bool canMove = true;
    void Start()
    {
    characterController = GetComponent();
    // Lock cursor
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
    }
    void Update()
    {
    // We are grounded, so recalculate move direction based on axes
    Vector3 forward = transform.TransformDirection(Vector3.forward);
    Vector3 right = transform.TransformDirection(Vector3.right);
    // Press Left Shift to run
    bool isRunning = Input.GetKey(KeyCode.LeftShift);
    float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
    float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
    float movementDirectionY = moveDirection.y;
    moveDirection = (forward * curSpeedX) + (right * curSpeedY);
    if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
    {
    moveDirection.y = jumpSpeed;
    }
    else
    {
    moveDirection.y = movementDirectionY;
    }
    // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
    // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
    // as an acceleration (ms^-2)
    if (!characterController.isGrounded)
    {
    moveDirection.y -= gravity * Time.deltaTime;
    }
    // Move the controller
    characterController.Move(moveDirection * Time.deltaTime);
    // Player and Camera rotation
    if (canMove)
    {
    rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
    rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
    playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
    transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
    }
    }
    }

  • @nosh247
    @nosh247 Před 2 lety

    Server Authority video please! :D

  • @sebase1161
    @sebase1161 Před 2 lety +2

    pls make a new part

  • @kiyochi7705
    @kiyochi7705 Před 3 lety +3

    when i clicked on this video
    it had 69 views
    lol

  • @GameJarne
    @GameJarne Před 3 lety +2

    the ghostbin doesn't work..
    Could you add another way to get the PlayerController Script?

  • @2esama
    @2esama Před rokem

    Shiiit amazing tutorial but where is part2 :(

  • @LuksaTV
    @LuksaTV Před 2 lety +2

    Why only one part :(

  • @MarshmallowBoy
    @MarshmallowBoy Před 2 lety +1

    the player controller script link isn't working. can you send me a pastebin or something please?

    • @shadbh2
      @shadbh2 Před 2 lety

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      [RequireComponent(typeof(CharacterController))]
      public class PlayerController: MonoBehaviour
      {
      public float walkingSpeed = 7.5f;
      public float runningSpeed = 11.5f;
      public float jumpSpeed = 8.0f;
      public float gravity = 20.0f;
      public Camera playerCamera;
      public float lookSpeed = 2.0f;
      public float lookXLimit = 45.0f;
      CharacterController characterController;
      Vector3 moveDirection = Vector3.zero;
      float rotationX = 0;
      [HideInInspector]
      public bool canMove = true;
      void Start()
      {
      characterController = GetComponent();
      // Lock cursor
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.visible = false;
      }
      void Update()
      {
      // We are grounded, so recalculate move direction based on axes
      Vector3 forward = transform.TransformDirection(Vector3.forward);
      Vector3 right = transform.TransformDirection(Vector3.right);
      // Press Left Shift to run
      bool isRunning = Input.GetKey(KeyCode.LeftShift);
      float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
      float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
      float movementDirectionY = moveDirection.y;
      moveDirection = (forward * curSpeedX) + (right * curSpeedY);
      if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
      {
      moveDirection.y = jumpSpeed;
      }
      else
      {
      moveDirection.y = movementDirectionY;
      }
      // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
      // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
      // as an acceleration (ms^-2)
      if (!characterController.isGrounded)
      {
      moveDirection.y -= gravity * Time.deltaTime;
      }
      // Move the controller
      characterController.Move(moveDirection * Time.deltaTime);
      // Player and Camera rotation
      if (canMove)
      {
      rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
      rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
      playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
      transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
      }
      }
      }

  • @avinaslama784
    @avinaslama784 Před 2 lety

    error !! Object reference not set to an instance of an object

  • @sufiansaeed9412
    @sufiansaeed9412 Před 2 lety +1

    How did u open 2 instances at 6:02

    • @zyapguy
      @zyapguy  Před 2 lety

      I built the game and just opened 2 of them

  • @fillament
    @fillament Před rokem

    bro how do you connect with people in mirror

  • @gamesfn5888
    @gamesfn5888 Před rokem

    Hey can you write the script in the comment? (because the link dont work)

  • @zSal
    @zSal Před 2 lety

    Was there a part 2?

  • @jens4085
    @jens4085 Před rokem

    Are you going to make a part 2?

  • @zanikowy_lek4060
    @zanikowy_lek4060 Před 2 lety +3

    Player controller script link not working ;(

    • @shadbh2
      @shadbh2 Před 2 lety

      just add your own player script, it doesnt have to be his, and if you do dont forget to add "using Mirror;", "if(!isLocalPlayer) { return;}", and change "MonoBehaviour" to "NetworkBehaviour"

  • @lgent2435
    @lgent2435 Před 2 lety

    Hello, where is the part 2?

  • @peny1981
    @peny1981 Před 2 lety +2

    When next part xD?

  • @blejertminecraft5771
    @blejertminecraft5771 Před 3 lety

    how did you opened 2 unity games at once?

    • @shadbh2
      @shadbh2 Před 2 lety

      Ctrl (command for laptop) + shift + B then click add open scenes then build and run

  • @hassunaama2
    @hassunaama2 Před rokem +1

    Next tutorial when :D

  • @yanhesap832
    @yanhesap832 Před 3 lety +2

    👍

  • @_GhostMiner
    @_GhostMiner Před 2 lety

    I'm starting to question If miking squid game by making a "game" about it is even worth it now. 😅

  • @michalcohen7747
    @michalcohen7747 Před rokem

    does this work with webgl?

    • @zyapguy
      @zyapguy  Před rokem

      It will if you use the transport called WebSockets Transport. Learn more here :mirror-networking.gitbook.io/docs/transports/websockets-transport

  • @greengames4722
    @greengames4722 Před rokem

    if anyone has an issue that the address is already is in use like me, use port 5555 or similar

  • @Adrielstudiodj
    @Adrielstudiodj Před 2 lety +1

    may u sand my the code pls i cant open the link

    • @shadbh2
      @shadbh2 Před 2 lety

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      [RequireComponent(typeof(CharacterController))]
      public class PlayerController: MonoBehaviour
      {
      public float walkingSpeed = 7.5f;
      public float runningSpeed = 11.5f;
      public float jumpSpeed = 8.0f;
      public float gravity = 20.0f;
      public Camera playerCamera;
      public float lookSpeed = 2.0f;
      public float lookXLimit = 45.0f;
      CharacterController characterController;
      Vector3 moveDirection = Vector3.zero;
      float rotationX = 0;
      [HideInInspector]
      public bool canMove = true;
      void Start()
      {
      characterController = GetComponent();
      // Lock cursor
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.visible = false;
      }
      void Update()
      {
      // We are grounded, so recalculate move direction based on axes
      Vector3 forward = transform.TransformDirection(Vector3.forward);
      Vector3 right = transform.TransformDirection(Vector3.right);
      // Press Left Shift to run
      bool isRunning = Input.GetKey(KeyCode.LeftShift);
      float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
      float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
      float movementDirectionY = moveDirection.y;
      moveDirection = (forward * curSpeedX) + (right * curSpeedY);
      if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
      {
      moveDirection.y = jumpSpeed;
      }
      else
      {
      moveDirection.y = movementDirectionY;
      }
      // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
      // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
      // as an acceleration (ms^-2)
      if (!characterController.isGrounded)
      {
      moveDirection.y -= gravity * Time.deltaTime;
      }
      // Move the controller
      characterController.Move(moveDirection * Time.deltaTime);
      // Player and Camera rotation
      if (canMove)
      {
      rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
      rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
      playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
      transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
      }
      }
      }

  • @VisibleMRJ
    @VisibleMRJ Před 2 lety +2

    still waiting for part 2

  • @muhammadtalhaali2541
    @muhammadtalhaali2541 Před 2 lety

    Sir part 2 where ?

  • @shubhampatel8193
    @shubhampatel8193 Před 2 lety +1

    Part 2 ??

  • @stickguy9109
    @stickguy9109 Před 2 lety +1

    This looks suspiciously easy

  • @thespecificgamer5816
    @thespecificgamer5816 Před 2 lety

    the websever is offline :(

  • @quiet7056
    @quiet7056 Před 2 lety

    sağol knk

  • @matterno
    @matterno Před 3 lety

    I was the first 12:21 minutes of the video like: "mhh... is this a real tutorial or a troll?"

  • @potatolegacy
    @potatolegacy Před 3 lety +2

    hey big brain can u tell us how to make movement with the new input system in package manager plzzzzz

    • @zyapguy
      @zyapguy  Před 3 lety

      I will try to do that sometime soon, thanks for the suggestion

    • @potatolegacy
      @potatolegacy Před 3 lety

      @@zyapguy im currently making a multiplayer game and u by diong this tuto i will love it
      thx for responding

    • @potatolegacy
      @potatolegacy Před 3 lety

      @@zyapguy u good youtuber not like dani boi

  • @xehn1491
    @xehn1491 Před 2 lety +1

    the playercontroller script page isn't working anymore

    • @shadbh2
      @shadbh2 Před 2 lety

      just add your own player script, it doesnt have to be his, and if you do dont forget to add "using Mirror;", "if(!isLocalPlayer) { return;}", and change "MonoBehaviour" to "NetworkBehaviour"

    • @shadbh2
      @shadbh2 Před 2 lety

      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      [RequireComponent(typeof(CharacterController))]
      public class PlayerController: MonoBehaviour
      {
      public float walkingSpeed = 7.5f;
      public float runningSpeed = 11.5f;
      public float jumpSpeed = 8.0f;
      public float gravity = 20.0f;
      public Camera playerCamera;
      public float lookSpeed = 2.0f;
      public float lookXLimit = 45.0f;
      CharacterController characterController;
      Vector3 moveDirection = Vector3.zero;
      float rotationX = 0;
      [HideInInspector]
      public bool canMove = true;
      void Start()
      {
      characterController = GetComponent();
      // Lock cursor
      Cursor.lockState = CursorLockMode.Locked;
      Cursor.visible = false;
      }
      void Update()
      {
      // We are grounded, so recalculate move direction based on axes
      Vector3 forward = transform.TransformDirection(Vector3.forward);
      Vector3 right = transform.TransformDirection(Vector3.right);
      // Press Left Shift to run
      bool isRunning = Input.GetKey(KeyCode.LeftShift);
      float curSpeedX = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Vertical") : 0;
      float curSpeedY = canMove ? (isRunning ? runningSpeed : walkingSpeed) * Input.GetAxis("Horizontal") : 0;
      float movementDirectionY = moveDirection.y;
      moveDirection = (forward * curSpeedX) + (right * curSpeedY);
      if (Input.GetButton("Jump") && canMove && characterController.isGrounded)
      {
      moveDirection.y = jumpSpeed;
      }
      else
      {
      moveDirection.y = movementDirectionY;
      }
      // Apply gravity. Gravity is multiplied by deltaTime twice (once here, and once below
      // when the moveDirection is multiplied by deltaTime). This is because gravity should be applied
      // as an acceleration (ms^-2)
      if (!characterController.isGrounded)
      {
      moveDirection.y -= gravity * Time.deltaTime;
      }
      // Move the controller
      characterController.Move(moveDirection * Time.deltaTime);
      // Player and Camera rotation
      if (canMove)
      {
      rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
      rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
      playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
      transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
      }
      }
      }

  • @shujaqureshi5370
    @shujaqureshi5370 Před 2 lety

    Plz make a part 2

  • @Notmyrealnamet
    @Notmyrealnamet Před rokem +1

    Zyapguy
    Sir , i need your help , i hope this comment comes to your sight..
    I am having problems with spawning my player , when i click HOST (server+client) , it throws null reference exception mirror.networkserver.addtransporthandlers()
    How to fix this , please help me