The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

Hi,
so I tried to make this work, but so far I didn't quite get there. (Also I'm pretty new to programming)
What I wanted to achieve is, that when I click at a point on my screen my character will move there, without moving through or into the walls.
I have a navigation2D node with a tilemap as a child. The walls have Collision that i added with the tile editor, and the floor has navigation.
So with getsimplepath I wanted to make my kinematicbody2D character move. I found a script online that would do that, but I figured out that that script just changes the position of the character, so it can't collide with the walls, so when I click into a wall the sprite (and collisionshape) of the character will overlap with the walls.
(this is how my navigation was made: https://www.youtube.com/watch?v=0fPOt0Jw52s)

  • It would be possible that I create an extra tilemap for the nav2D node that takes the size of the sprite into account so it wouldn't overlap with the walls, but that would mean, if I create bigger or smaller mobs they would need there own navmesh again. (but still I'm not sure if changing the position is the best solution)
  • Or I could make the character move by physics? so it collides with the wall when it gets to close. But then I wouldn't know how to let it still get to it's target.

So I hope I could get my problem across. If somebody can point me in the right direction or has some code or anything really to help me out, I'd be really thankful :D

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.