Click To Move | Unity RPG Tutorial #1

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024

ความคิดเห็น • 49

  • @Mogg798
    @Mogg798 11 หลายเดือนก่อน +10

    Good tutorial, had a couple problems with implementing it in my project, here is how i fixed if anyone has similar issue:
    Had an issue with Input.mousePosition in PlayerController script not being read, I had to go into player settings (Edit > project settings > player) and find the Active Input Handling dropdown and select "both".
    This fixed my errors but player wouldn't move on mouse click, as I didn't have any clickable layers set so, for temporary testing I just went to the inspector of the character and changed the clickable layers to "everything".

    • @leerc7721
      @leerc7721 9 หลายเดือนก่อน +2

      omg thank you so much Mogg! 😃

    • @wernerschreuder9800
      @wernerschreuder9800 หลายเดือนก่อน +1

      Life SAVER!

    • @Mogg798
      @Mogg798 หลายเดือนก่อน +1

      @@wernerschreuder9800 good luck on your project

  • @metamorf9247
    @metamorf9247 6 หลายเดือนก่อน +4

    It's probably too late to give advice, but for those who stumble upon this video, I recommend turning on DESTROY in the effect tab in "Stop actions" so that the effects are removed

  • @AsherKadmiel
    @AsherKadmiel 7 หลายเดือนก่อน +2

    at first it wasn't working but then i realized that i had to select the default layer for the player controller script, Thanks !

  • @farbod376
    @farbod376 ปีที่แล้ว +23

    if you face the code problem where your player reset rotation on arrival you can use this in void FaceTarget() function instead =
    void FaceTarget()
    {
    if (agent.velocity != Vector3.zero)
    {
    Vector3 direction = (agent.destination - transform.position).normalized;
    Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
    transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed);
    }
    }

    • @nikson12gg
      @nikson12gg 9 หลายเดือนก่อน

      Perfect

  • @Patterno96
    @Patterno96 11 หลายเดือนก่อน +1

    Great video! Thanks a lot for the great explanation, that's what I was looking for!

  • @Pro-xm8jb
    @Pro-xm8jb ปีที่แล้ว +5

    Ur amazing its a crime how underated dis is

  • @albertgarcia3048
    @albertgarcia3048 ปีที่แล้ว +2

    Easy, clean and very easy to follow!! Subscribed :D

  • @yakamozz
    @yakamozz ปีที่แล้ว

    Nice work👍🏻

  • @King88Martyn
    @King88Martyn ปีที่แล้ว +3

    Thanks for the tutorial. How would you go about expanding this to continually move towards the mouse if you hold the button down? Similar to in Diablo.

    • @Its_Pogle
      @Its_Pogle  ปีที่แล้ว +1

      If you're using the new Input System like this video, check out this approach. stackoverflow.com/questions/59837392/how-to-repeat-function-while-button-is-held-down-new-unity-input-system.
      Otherwise, if you're using the old Input System add this to update...
      if(Input.GetMouseButton(1))
      { ClickToMove(); }

    • @King88Martyn
      @King88Martyn ปีที่แล้ว

      @@Its_Pogle Thanks, I'll give it a go.

    • @Semikaze
      @Semikaze ปีที่แล้ว

      I can help if you still have the problem. But diablo need the original old input system that i also use :) I have a ready script and you just need to adjust some things in navmesh agent. simple

  • @vastril5391
    @vastril5391 6 หลายเดือนก่อน

    Hi I have a problem where the character does reach the destination, but lags behind and teleports as the animation happens. It does arrive yes but it does that where it is buggy and laggy. It does work perfectly though when clicking the area and it arriving there.

  • @brianparkhurst5352
    @brianparkhurst5352 2 หลายเดือนก่อน

    Error with your Circle material, seems to be a particle shader error. Cant find the shader you are using.

  • @farbod376
    @farbod376 ปีที่แล้ว +1

    my player controller somehow stopped working! it was all good , i cant figure out what happened,i even created a new project watch the tutorial few times to make sure i get everything right, it wont even work in the new project too! how come it was working few hours ago and wont work anymore , what is wrong with unity ? please help me

  • @phlovejoy
    @phlovejoy 4 หลายเดือนก่อน

    If Input Actions does not appear on your create list, return to package manager and download Input System from Unity Registry.

  • @Oathkeeprr
    @Oathkeeprr 3 หลายเดือนก่อน

    if anyone is having an issue with the character's FaceTarget snapping after they stop moving. simply check to see if the velocity is zero. and if it is just return.
    void FaceTarget()
    {
    if (agent.velocity == Vector3.zero) return;
    Vector3 direction = (agent.destination - transform.position).normalized;
    Quaternion lookRotation = Quaternion.LookRotation(new Vector3(direction.x, 0, direction.z));
    transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * lookRotationSpeed);
    }

  • @GreenuniverseEuro
    @GreenuniverseEuro 6 หลายเดือนก่อน

    no matter what I click or do ClickToMove(); never gets called??

  • @Nomike2212
    @Nomike2212 11 หลายเดือนก่อน

    hey man can u make more of this series please

  • @carolineasala7830
    @carolineasala7830 ปีที่แล้ว

    This is cool

  • @ukaszgrabski2811
    @ukaszgrabski2811 7 หลายเดือนก่อน

    Add remaining distance checking in FaceTarget so it does not rotate like an idiot in the end :P

  • @AlejandroMartinez-iz2kf
    @AlejandroMartinez-iz2kf ปีที่แล้ว

    Hola, estoy desarrollando un videojuego estilo RPG y me he encontrado con el problema de los pisos superiores e inferiores, al buscar diferentes formas de fade, transparect, etc. no encuentro la solución deseada, alguien ofrece el servicio para que me ayude a solucionar mi problema?

  • @curiouscleft9535
    @curiouscleft9535 ปีที่แล้ว

    Why am I not seeing navmeshsurface? I am getting an error on the environment game object. saying there is a missing script.

    • @Its_Pogle
      @Its_Pogle  ปีที่แล้ว

      You'll have to download the 'com.unity.ai.navigation' package to see the script.

  • @Lodreus
    @Lodreus 8 หลายเดือนก่อน +1

    I'm getting error on input.Main.Move.performed += ctx => ClickToMove();
    "Severity Code Description Project File Line Suppression State
    Error CS1061 'CustomActions.MainActions' does not contain a definition for 'Move' and no accessible extension method 'Move' accepting a first argument of type 'CustomActions.MainActions' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp

    • @lin_lin_lin
      @lin_lin_lin หลายเดือนก่อน

      make sure you save the changes made to the CustomActions file (in the Input Actions editor window). you can either just click the Save Asset button, or check the Auto Save box.

  • @shinosmodspot4267
    @shinosmodspot4267 5 หลายเดือนก่อน

    i cant figure any thing out would u help me pog?

  • @CaptinnDuckLive
    @CaptinnDuckLive ปีที่แล้ว

    when I start the game the camera goes underground, I don't know how to fix it.

    • @Its_Pogle
      @Its_Pogle  ปีที่แล้ว

      Make sure the offset Vector3 reference on the Camera Controller is given values (6 on Y and -5 on the Z)

    • @CaptinnDuckLive
      @CaptinnDuckLive ปีที่แล้ว

      @@Its_Pogle I got it working

  • @adventureswithshaggy
    @adventureswithshaggy ปีที่แล้ว

    After I did the code, I noticed that when the player object gets to the click position, say he is facing right, once he arrives to the spot I cliked he faces left (or to the front i guess), anyway to fix this.

    • @Its_Pogle
      @Its_Pogle  ปีที่แล้ว

      I've run into this error when creating this system too. You may have made a mistake within the FaceTarget(). Double check it or just copy it from the github link!

    • @issykidding
      @issykidding ปีที่แล้ว +1

      Sorry, I realized that this is not an issue, but just how the code works.
      edit: Going to just edit this instead of putting a new comment. I figure out how to make the character stay in the same direction you move. Put the variable Vector3 direction at the top with the movement variables. Move the "direction = (agent.destination - transform.position).normalized;" to the ClicktoMove function. That way it will keep the direction until the mouse is clicked again.

    • @joaofrugiuele3588
      @joaofrugiuele3588 ปีที่แล้ว

      @@issykidding Just change FaceTarget call from Update to ClickToMove and crank up LookRotationSpeed for 80 times

    • @joaofrugiuele3588
      @joaofrugiuele3588 ปีที่แล้ว

      Another solution I just found is to put 'if(lookRotation.x != 0 || lookRotation.y != 0)' inside FaceTarget function, right above transform.rotation command

    • @voidvisiongames
      @voidvisiongames ปีที่แล้ว

      @@issykidding genius, thanks

  • @xiaonisha5952
    @xiaonisha5952 ปีที่แล้ว

    I cant find AI Navigation package kinda unlucky gg

    • @abuuk
      @abuuk ปีที่แล้ว +1

      Its built in, go Window > Ai > Navigation

  • @Vintosexe
    @Vintosexe ปีที่แล้ว +2

    I 'm so sick of it ! again I did everything as in the video and again it does not work ! your build is also not working as usual for everyone on TH-cam

  • @aes0p895
    @aes0p895 ปีที่แล้ว +1

    you go through these steps way, way too fast. and the fast forwarding is really frustrating.

  • @TheButteryGorilla
    @TheButteryGorilla 4 หลายเดือนก่อน

    ive used a character from the pack that you used but i cant find the avarat for it for the animation controller @PogleDev