Click To Move | Unity RPG Tutorial #1

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

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

  • @metamorf9247
    @metamorf9247 9 หลายเดือนก่อน +10

    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

  • @Mogg798
    @Mogg798 ปีที่แล้ว +11

    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 ปีที่แล้ว +2

      omg thank you so much Mogg! 😃

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

      Life SAVER!

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

      @@wernerschreuder9800 good luck on your project

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

      I don't suppose you'll check this and say how you set clickable layers to everything. Is this option supposed to be under the NavMeshSurface in the inspector?

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

      @Marzipanilla it should be on a dropdown on one of the objects in the inspector, maybe on nav mesh agent if i remember correctly(?) not at my pc rn so i cant check, perhaps search it on google if you cant find it

  • @AsherKadmiel
    @AsherKadmiel 10 หลายเดือนก่อน +4

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

    • @khrystyna_she
      @khrystyna_she 2 วันที่ผ่านมา

      I just spent 20 min trying to figure out why it doesn't work. You saved me 😅

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

    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);
    }
    }

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

    If anyone is having problems with Orthographic Camera, e.g. character is not moving on clicked, check out your values for Camera Clipping Planes. I've managed to solve by setting Near to 0.01 and Far to 1000. In my case, negative values for Near Clipping Plane caused the issue. Orthographic Size has been set to 15, btw.

  • @Waszzup
    @Waszzup ปีที่แล้ว +5

    Ur amazing its a crime how underated dis is

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

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

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

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

  • @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 9 หลายเดือนก่อน

    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.

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

    i got stuck with the circle mat render

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

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

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

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

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

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

  • @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

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

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

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

    hey man can u make more of this series please

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

    Nice work👍🏻

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

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

  • @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.

  • @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?

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

    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)

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

      @@Its_Pogle I got it working

  • @Lodreus
    @Lodreus 11 หลายเดือนก่อน +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 4 หลายเดือนก่อน

      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.

  • @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

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

    This is cool

  • @cbjaxx1413
    @cbjaxx1413 12 วันที่ผ่านมา

    Very Little explanation on why you are writing the methods and how they actually work. you don't have to speed through it either.

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

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

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

    mirrored ever file, and every keystroke - still no luck - also went through all comments here - looks like this will not work on Unity 6 and newer

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

    I cant find AI Navigation package kinda unlucky gg

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

      Its built in, go Window > Ai > Navigation

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

    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 ปีที่แล้ว +2

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

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

    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);
    }