Creating a Diablo Like Click To Move System in Godot 4

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

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

  • @johnpopilek
    @johnpopilek 7 หลายเดือนก่อน +39

    Just in case anyone comes by this video and has issues like I did (I'm using 4.2.1)
    Line 12 changed to:
    if(navigationAgent.is_target_reached()):
    line 18 changed to:
    var targetPos = navigationAgent.target_position

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

    I watching this on 2024, there are even MORE changes in 4.3 version but this helped me a LOT to understand how to navigate throught documentation and make the needed fixes!
    thanks!

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

      I really need to update this but I'm glad it worked for you!

  • @Luna_Kobold
    @Luna_Kobold ปีที่แล้ว +28

    there seems to be a crash if you click an area that has no objects in it? seems to be from position not existing. likely an easy fix but something to keep in mind!
    edit: was a super easy fix, just put this between print(result) and the navigationAgent.target_position lines:
    if result.size() < 1:
    return

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

      result.is_empty() works as well

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

      Thank you! Squashed a bug I didn't even notice was there!

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

      thanks a lot

    • @Savage-tv4hs
      @Savage-tv4hs 6 หลายเดือนก่อน

      @@WalkerRileyMC Even simpler: `if result:`

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

      Thanks! Implemented the movement and came back a few weeks later to adress this bug.

  • @vila4480
    @vila4480 ปีที่แล้ว +8

    Wow this has got to be one of the best tutorials I've ever done. Thank you for not skipping the code fixes when you made mistakes.
    I'm moving from Unity to Godot so I'll keep an eye on your future tutorials.
    Please do more! 👍

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

      I will definitely be doing more! If you have any suggestions be sure to let me know or put them on my suggestions board!

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

    Thank you so much! I’m working on something very different (a 3d point and click) but I couldn’t get the ray casting working, this tutorial helped so much

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

    Very good Tutorial I found out that you can also enter Is_action_pressed at Input then you can also do the mouvment in such a way that the left mouse button has to be held down so that you can move, very helpful :)

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

    I was following your video along and programming in C# xd managed to get the same results as you, which I really appreciate it

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

      Any chance you can share the C#

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

    Nice. Took me a while to find out that "set_target_location" has been changed into "set_target_position".
    Update: wow. I paused the video just before you have the same error. :-)

  • @TravisHouston-ri5cz
    @TravisHouston-ri5cz 10 หลายเดือนก่อน +2

    any chance we can get more on this? Like an actual character with walking animations? Maybe even a point and click combat system like runescape or diablo? great video and lvoe the way you explained this. Very much what I was looking for but cant find the next step video.

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

    This could be a nice little addition to the code:
    func face_direction(target_pos : Vector3, delta : float) -> void:
    var new_transform = transform.looking_at(target_pos, Vector3.UP)
    transform = transform.interpolate_with(new_transform, turn_speed * delta)

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

    Hello there, it is a really good tutorial :D. Can you make a tutorial about rts selection with this?

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

      I'll put it on my list.. I was talking to someone about making an RTS framework for Godot 4.

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

    I love this, how would you lerp the look_at though? I am trying to have a bit of initial moment and rotation as the character movement is quite jerky for the initial movement.

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

      In case you haven't solved this. This is what I found:
      Replace the content of the faceDirection method to: rotation.y=lerp_angle(rotation.y,atan2(-velocity.x,-velocity.z),.1)
      That's it! It works perfectly :)

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

    Hello it was really grate. can you continue this as a series. I really liked it tnx so much

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

    amazing tutorial! I am suprise I made it work on godot 3.5! i am so happy! you are the best!

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

    Cool, you can use this for mini map movement. You just need to change the camera and projection.

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

    Nice video! Would be nice if you included lerping during the faceDirection function.

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

      Your right I should have

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

      Here's how I did it:
      look_at(Vector3.FORWARD.rotated(Vector3.UP, rotation.y).lerp(direction, 0.1) + position)

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

    THAAANKKK YOOOUUUU!!!

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

    nice video this kind of system reminds me of the rts games like age of empires, rise of nation etc...

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

    7:00 _ready runs when the node is in the tree and all its children are ready too
    this is important when you create nodes from the code
    create node, setup parameters of the node, add node to the tree, now onready vars are set and _ready function is called

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

    Thank you kindly for your amazing help!

  • @gabriel-xh8uo
    @gabriel-xh8uo ปีที่แล้ว

    TNX BRO BEST TUTORIAL

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

    Hi! This is a pretty nice tutorial and worked perfectly.
    Do you have a video on how to make movement like league of legends? Pretty much camera follows you all the time on isometric 3D and the character looks instantly to the direction you started moving to... If not, could this be a video, please? XD

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

      I think, you have to do these steps:
      1) set the camera node as a child of the CharacterBody instead of the world, then it will move with the character
      2) at 8:40 when he sets the mouse event with "is_action_just_pressed", you have to replace that with "is_action_pressed", I think that's what it's named. Anyway, a function that keeps triggering while you hold down your button. "just pressed" is only for one frame after pressing.
      Maybe 3) move it from the _input to the _process function, in case _input doesn't check every frame, then _process will.

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

      @@nightmareTomek I can't believe this comment was only 2 weeks ago, I advanced so much in that time lol. But yeah, I got it some time ago using the 1) you meantioned, thanks.

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

      @@nightmareTomek I just arrived at this point too. I want the camera to follow the player but dont change its rotation. When setting it as child of the player the camera keeps rotating with the player-object... Any clues on how to keep the camera in the starting angle like in Diablo?
      Worth mentioning is that I implemented movement by mouse via raycast I guess.

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

    Good tutorial, getting a really inconsistent error about not being able to get the position of result because it's a dictionary though

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

    Yes, thank you!

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

    How on earth did you get the like buttons to do that at 28:30? (im on PC)

  • @gim-ori
    @gim-ori ปีที่แล้ว

    awesome! thanks!

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

    Thank you very much

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

    Hi! I have the problem with Invalid get index 'position' (on base: 'Dictionary'). When I try just to print a result everything works fine, but when I try to print result.position or move player, I have the error. I've checked the solution in the comments, but it didn't work. What can be the reason? TIA

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

      Ok, I found the solution, here it is:
      nav_agent.target_position = result.get("position",ray_end)
      But now player moves without stop and in opposite direction

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

      So, found this too. I am using camera rig, because I have isometric view and use couple camera's to make walls transparent. So, I can't use camera mount point that is over my player and it use Camera like in the middle of the map, so mouse click and as I tried to implement character turning over the mouse doesn't work for me properly(

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

    I've done this verbatim 3 times and I haven't been able to get my CharacterBody3D to move, started it with new projects and updated the coding word for word and I get my rayQuery results back but my character just seems to refuse to move. I'm sure it's some newb issue I'm having but definitely frustrating!

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

    what should I do if the player goes to (0,0,0) after starting

  • @marshampson2009
    @marshampson2009 29 วันที่ผ่านมา

    I'm trying to make a game that controls like OldSchool RuneScape- most importantly, point-and-click walking along a grid of tiles. Is this possible to build off of this system?

    • @FinePointCGI
      @FinePointCGI  29 วันที่ผ่านมา

      You can. It uses a very similar system in your navmesh you can choose the density of the mesh ant that would achieve this result

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

    Any chance of an updated version of this in C#?

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

    Do you have a point and click version for 2D as well? I think I understand the basics but am having trouble understanding how the NavigationAgent2D works with more complex commands like attack and skill commands.

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

      I don't however I can make something for it what are you thinking?

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

      ​@@FinePointCGI I'm making an RTS combat system. I have unit selection down but I'm having trouble integrating the new navigation system when implementing skills [_move_to_target(), _attack_target(), _special_target()]
      With the premise being RTS systems have:
      controller = player
      pawn = "in game actor".
      and the intended outcome:
      if selected:/
      if controller.InputEvents(["right_click", "left_click", "special_attack", etc]):
      pawn.navigationagent.target_position = mouse_position
      pawn.statemachine = InputEvent
      pawn.enum.Command = InputEvent.animation.play()
      I hope that made sense.

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

      ​@@FinePointCGIit would be great if you make a 2d tutorial

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

      I would also like a 2D tutorial, I’ve literally just started using godot

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

    Is there any way to get the raycast to ignore the player and its model, so that you can click 'through' it? Stuck with this bit! Thank you for the video

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

      You can put them on different collision layers and only raycast that layer

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

    I have an issue with the point of the PathFinder : whenever it is entering a new area of the navigationRegion (the one we bake), a new point is generated, thus forcing my character to stop and start again until reaching the final position. Any one met this issue aswell ?

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

    thank you for putting this together, super helpful!

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

    I noticed the bug as you were writing it, thinking "that can't be right"... good tutorial nevertheless.

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

    Everything else seems to work, but my character doesn't move. It only moves when i press my jump button that is located in func _physics_process(delta): . Does anyone know why this happens?

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

      Because for some reason when you click, the result is empty. I do not understand why, but I see in forms the same code he uses. It is in "Ray-casting" and that chunk of code as an example is in _physics_process(delta) function
      I guess after update it is meant to be there now.

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

    how would i attactch that camera to my player so it moves with the player

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

      found a solution ? :)

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

      You should be able to just drop the camera underneath the player and it will follow the player.

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

    Seems like the player never reach the click position. It stops before it reach the mouse click position. But its velocity never stops. I realized when I added a character and try to play run animation, which never stops.

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

      That's interesting. I know there is a stop distance parameter in the navigation agent setting so that may help with your issue

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

      @@FinePointCGI Thanks for the reply and thanks for the video.

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

      Is the Stopping Distance parameter still in Godot 4.2? I couldn't locate it.@@FinePointCGI

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

    Ah, there's a problem with my godot, when I generate the script, several codes appear on the screen already written, and almost all the codes you write do not appear in my gdscript

  • @QqQq-bf8bd
    @QqQq-bf8bd ปีที่แล้ว +1

    i made 3d game in godot 3.5.1 and export apk, but not working in mobile. splash screen open and app has been stopped, 2d game working properly but 3d game not working in mobile (snapdragon, adreno) ,i will try single cube and camera but same result. please help what i do

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

      It sounds like your phone doesn't support the 3d part of the engine what phone is it? You could try gles 2

    • @QqQq-bf8bd
      @QqQq-bf8bd ปีที่แล้ว +1

      @@FinePointCGI thanks for the reply and yeah morning i fixed the error to change gless2 render

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

      Hey I'm glad you fixed it!

    • @QqQq-bf8bd
      @QqQq-bf8bd ปีที่แล้ว +1

      @@FinePointCGI thanks

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

    can you make a click to move system using apply_force?

  • @MarkRoe-w5e
    @MarkRoe-w5e ปีที่แล้ว

    From 11:30 I feel like you are just reading out what you are typing and omitting the explanation.

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

    i have this error:
    Cannot call method 'is_navigation_finished' on a null value.

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

      That error means the object yoru calling is_navigation_finished on is null

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

    I followed the exact tutorial and it works BUT I get this error face_direction(): Node origin and target are in the same position, look_at() failed.

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

      OK, I did manage to fix it a little so I'm leaving this comment here in case anyone faces the same problem. The error has to do with the navigation agent path desired distance and target desired distance, 0.1 causes this error with me, changed their value to 0.5 still an error, changed it to 0.75 and the error is gone ! I'm not sure why, maybe a mouse sensitivity issue ?

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

      @@ahmed_mo2nis_productions I did a few test and the Player Y position also causes this. I put it a little higher and it fixed it.

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

    what do you think unity engine can do this easier than this?

  • @shizukaryujoukai2465
    @shizukaryujoukai2465 8 หลายเดือนก่อน +2

    Any update to this? Its not working, im getting all of the data but its not moving.
    Edit: I fixed it

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

      How did you manage to fix it?

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

      @@CocolandiaYT if you still need help, I had the same problem and it turned out the navigation region height of 0.01 was too low, I set it to 0.05 and it works now

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

      @@CocolandiaYT I made it from scratch in the middle of the process and forgot to bake the navigation mesh again. So the mesh was tiny. I still got collision numbers but it just didn't navigate.

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

    Makes me wonder if I should make some CRPG with this for a future game.
    Much appreciate the help and contribution, @FinePointCGI

  • @LynxDev-IO
    @LynxDev-IO 3 หลายเดือนก่อน +1

    "now, hopefully, if we click..." (crashes)

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

    I followed your code exactly, but for some reason it doesn't work at all. If I follow all the code up to printing out the result, it remains blank (even after updating the "project_ray_origin" to "project_ray_normal"
    if I change the print to "print(result.position)" then I get the error" Invalid get index 'position' (on base: Dictionary)" any ideas what this is all about?

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

      Result is a dictionary so print that and see what it comes back with. I wonder if they changed how it goes.

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

      @FinePointCGI I'm very new to godot (switching from Unity 😁) how do I print the dictionary?

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

      Just print(result)
      If your using c#
      GD.Print(result)

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

      @FinePointCGI oh! I did that before, and it's just blank. Which is very odd. Just gives me "{ }"

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

      What does your raycast look like? Currently it's not hitting anything

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

    seems global_position.direction_to(targetPos) keeps shoving 0,-1,-0 into the variable.
    Frustrating as it worked fine in testing but soon as I moved the code to the prototype game this started up. No difference in anything other than it's a different game. targetPos is populated with the correct values...just seems when I try to do a direction_to it decides to set it to near the origin. Not 100% sure why one works and the other doesn't to be honest.

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

      Still no idea. Copy and pasted the entire code and it worked, but honestly absolutely nothing changed (and I checked...thrice).

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

      the cods isn't the only thing to check try making sure the nodes are all the same as well who knows could be one simple thing.
      @@WalkerRileyMC

  • @shinobi2ro
    @shinobi2ro 4 วันที่ผ่านมา

    like and subscribe for this tysm bro

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

    If you're stuck and your navigation agent is barely moving, switch the ray origin and ray normal piece of the code, and it should work. var from = camera.project_ray_origin(mouse_pos)
    var to = camera.project_ray_normal(mouse_pos) * ray_length - (from) , also Path Desired and Target Desired didn't work for me if I changed it from the default settings

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

      That's what i was thinking. Using project_ray_origin for both only works if the camera position is using an offset of only one axis.

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

    Hello brother, can you provide codes for godot 3.5.2?
    Godot 4 on linux has too many bugs. I can't even open the project 😭.

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

      What error are you getting? I may have someting like that allready made I think its called navigation in 3.5 i think?

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

      ​@@FinePointCGI Hi, can I ask for help in your discord server? I'm completely new to programming.

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

      Yeah it's open to anyone link is in the description

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

    Ok so A

  • @codzombiespro-b5f
    @codzombiespro-b5f 10 หลายเดือนก่อน +7

    wasted 5 hours because this video outdated, good shit dude

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

      Worked for me with 4.2.2

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

      When you say outdated do you mean the process no longer works or that there's a more efficient way to do it?
      Or is this a joke about how much Godot changes between releases?

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

    struggle to hard with the camera setup. really demotivating. developing feels so lonely and empty. like you are in the ocean struggling to survive on high waves while milions of people are around you and nobody is trying to help and when help comes it is a cement block on the feet xD googling since 2 hours how to fricking stop the nav agent player when he enters an area but apperently nobody on google tried to ever do that in godot xD

  • @QqQq-bf8bd
    @QqQq-bf8bd ปีที่แล้ว +1

    i made 3d game in godot 3.5.1 and export apk, but not working in mobile. splash screen open and app has been stopped, 2d game working properly but 3d game not working in mobile (snapdragon, adreno) ,i will try single cube and camera but same result. please help what i do