Issue Adding Custom Built Virtual Joystick to Main Game Scene (Despite It Working in Test Scene)

Godot Version

4.6.3.stable

Question

Greetings.

Today I have been learning how to create a virtual joystick for a game I’ve been making as I study and learn (I’m still new to developing but learning fast). I was watching this video as a tutorial on how to make a joystick for use and have gotten to 24:30 where the joystick is tested (video: https://www.youtube.com/watch?v=w7vJNxO5beA). I know that there are plugins that will do this for me, but the goal is to learn how to do it myself not just “have working joystick”.

Now, up until this point, everything is working fine and as far as I know I understand what I’ve built and how it works. However, when I instantiate the joystick scene into the main game scene instead of a blank test scene, the movement that works in the test scene does NOT work in the main game scene. It is as though being in the main game scene doesn’t allow the joystick to detect my finger on the screen anymore.

I am working from a computer that has a touchscreen, so Ive been able to test with actual touch screen input instead of emulating it with the mouse. And everything works up to this point. But now I am at a loss because I simply do not understand what could make it so that adding the joystick scene to one scene will work but not another.

If anyone has any ideas what I can look into to correct what is happening, I would very much appreciate it. The game is essentially finished at this point and works fine, but this final touch will allow it to be used on a mobile device instead of requiring it be played on a device with a keyboard.

Thank you for your time. If there is any information that will help anyone trying to assist, I will respond as promptly as I am able to with it to investigate.

EDIT:

  • Here is some footage of the issue as it happens. The first scene is the joystick scene file itself (funtioning as intended), the second a simple test scene wher the joystick was added (still functions) and the third the main game scene where the joystick doesnt respond at all (added the same way it was added in the test sene).
    https://youtu.be/Ev4N3x-I6ZY

Use 4.7 and the built-in virtual joystick that comes with it.

In the bottom Debug panel the “Misc” tab can show you what object is being clicked on. This can help you deduce what is blocking inputs

I appreciate you taking the time to reply, but as I mentioned in the post the goal I’m inquiring about isn’t to simply “have a functional joystick” as that can be done easily with various available addons (my project currently uses one of these addons as a temporary stand-in while I learn the skills to build them myself). The goal I’m writing for assistance with is to actually learn to make the feature rather than being dependant on premade versions created by others with that knowledge, and overcoming the challenges along that journey.

In learning to build one I have run into an issue that I have been unable to determine the cause for, so I came here to seek the knowledge of others who may have experienced the same, or who may know how to correct and avoid my error (whatever it is) in the future).

But I do appreciate you taking the time to reply…especially when no one else had yet. Thanks. <3

Thank you. This is something I wasn’t aware of and it looks like it will be very helpful in solving the error. I will give this a go and update here based on how that turns out. Cheers :slight_smile: .

Fair enough. I didn’t have a lot of time to reply yesterday. I’ve used those addons before. I’ve made my own. Both are a NIGHTMARE to debug. Hence, my suggestion.

If this is just for funsies, then enjoy the journey. @gertkeno’s suggestion should help you out.

Ok, so using your suggestion I was able to determine a bit of what seems to be happening:

- In the test scene, things work. In the main game scene, things do not.

  • When clicking in the main game scene the debugger says I am clicking a MarginContainer. At first I thought this was the MarginContainer that was part of the joystick, and since that was a “me thing” I did while studying the original video (and thus a deviation from the video’s instructions) i removed it to conform to the video instead…and nothing changed. The debugger still said I was clicking a MarginContainer. Yet there was no margin container in my main scene.
  • Then I realized that my “HUD” scene, which is instanced in the main scene, has a MarginContainer, and that this must be what is registering as being clicked. I added an instance of the HUD to the test scene and confirmed that the HUD is the issue somehow…the moment the HUD is added to the test scene the stick stops recognizing touch screen input, as though the HUD is blocking it from feeling my gentle caress.

This does still seem very confusing to me, however, as the addon joystick I added as a temporary substitute while I figure this out has NO problem at all being used, and the HUD doesn’t interfere with its ability to register touch input.

Our issue hasn’t been solved yet, but we’re definitely closer to understanding what is causing the error and correcting it (thanks for that by the way :slight_smile: appreciate it).

This isn’t quite for funsies lol. I need to learn the skill to make these things so that I can create custom ones with custom assets and such. Relying on the ones others make is great when you just need a quick feature implemented and have no requirements about what it looks like (like me tossing one in to have access to touch controls while i build the project) or how it works, but the moment you need something specific (like needing it to look a certain way and such as I do) about it you either have to understand how it works to edit it or make it yourself (as I know you know), or you have to get the person who made it to make a special version just for you (highly unrealistic)… so here I am.)

The journey continues :slight_smile:

In that case, I recommend you read this post:

And then give us enough information to help you.

As far as I am aware, this specific issue hasn’t been posted elsewhere, though if I have overlooked something you are aware of, I am happy to receive a link from you and head over to the post I didn’t know about instead of asking here. It’s a big website so it is very possible I missed something.

As to the latter, I am uncertain what other information I could provide that I haven’t for people to be able to assist. I have been as detailed as possible throughout, and even stated in my original post that “if there is any information that will help anyone trying to assist, I will respond as promptly as I am able to with it to investigate”, recognizing that there may be something someone needs to know that I wasn’t aware should be shared and addressing that from the beginning just in case. So far, no one has requested any specific information that they believe they would need to be able to assist, so I still do not know what information I could be providing that I haven’t that would help. :frowning:

I feel that if I understood the situation well enough to be able to do so perfectly, that would indicate I understood the situation well enough not to have needed to seek assisstance from anyone else at all in the first place, and clearly I am not that knowledgeable in this particular context :laughing: .

I have made a “solution” of sorts using the knowledge gained from your information about the debugger and such:

- I have moved the joystick itself out of the MAIN scene and built it into the HUD scene which it was in conflict with (which seems an appropriate place for it to be anyway since the HUD is the HUD…).

This has resolved the issue. I haven’t learned the WHY of what has caused this to occur, but at least we have found a solution to the issue even if I don’t understand it. For now, perhaps that may be enough. So thank you for taking the time to share what you could and giving me the thing that would get me this far. I appreciate the help very much stranger. Enjoy the rest of ur day. :slight_smile:

For future reference, you provided no code, and no scene tree. If you want a concrete answer, then that’s what we need. Not a link to a tutorial we would have to follow to be able to help you. Which to be clear, was spelled out in the post I linked you to. Because I don’t want to have to explain that over and over again. You are the fifth person I’ve linked to that post just today. That post was created based on a lot of discussion here and I wrote a lot of it.

Please keep in mind we are all volunteers here. We don’t get paid to help you.

Glad you got your answer.

Sounds good, after checking that Misc tab it’s helpful to look at the Scene tree, specifically while playing the game a new “Remote” tab will be added showing how the game’s actual scene tree is laid out. Your HUD may have been on a CanvasLayer above the other nodes, though I’d recommend this layout if you are using global/autoload UI to parent it to a CanvasLayer. It does mean your joystick may also need to be reparented to a CanvasLayer so it can be layered above others without messing up the scene tree.