Character Controller can not find config.json file

I have been trying to use the character controller found here but when I try to run it, I am getting an error message saying how there is not such file or directory

from characterController.PlayerController import PlayerController

is my import statement

        self.mydir = os.path.abspath(sys.path[0])
        self.mydir = Filename.fromOsSpecific(self.mydir).getFullpath()

is how I am accessing the directory

    def loadPlayer(self):
        self.cTrav = CollisionTraverser("base collision traverser")
        self.player = PlayerController(self.cTrav, self.mydir + "/config/configs.json")

that is how I am loading the player

that is how my file system is arranged

That is the error message I am getting, I have tried to move the file around from the config directory to other ones and then change the path. Also renaming the file but those did not work. Does anyone have any idea of why it isn’t working or can help me with debugging?
Many thanks.

It looks like PlayerController needs an OS-specific path, whereas you are specifying a Panda-style path, with forward slashes.

Convert it by passing Filename(self.mydir, 'configs/configs.json').toOsSpecific()

Thank you for the reply, should I put this in the self.loadPlayer() method? for example, if I put:

    def loadPlayer(self):
        self.cTrav = CollisionTraverser("base collision traverser")
        self.jsonDir = Filename(self.mydir, 'configs/configs.json').toOsSpecific()
        self.player = PlayerController(self.cTrav, self.jsonDir)

That looks like it should fix this issue, give it a try.

I would have thought it would work too. same error but just with a different path.

It looks like there is a typo in the path, I wrote configs/configs.json whereas it is actually in config/configs.json.

Yes that fixed that error thank you! Do you know how i should have my data folder from the character controller set out in my file system?
I currently have it like this

but it is giving me the error message

I have tried to change the file paths within the configs.json file but to no luck(tried changing the …/ to ./). Is there something wrong with my file system?

I don’t know anything about that snippet, sorry; pinging @wolf.

No problem. Thank you for your help anyway!

I’ve never tried the character controller on windows, which is why I have missed that path specific problem. It’s good that you found it though, will implement a fix for that in the next version.

Regarding the data folder, you could put that wherever you want as long as the path is correctly set in the config json file. I’ve rarely used relative paths with it, but as long as the models can be found anywhere in the configured search paths it should be fine. In your example, you may want to set something like model-path $MAIN_DIR/data/ then you should be able to set the configuration in json to “model”: “actor/Fox”.

That fixed the issue i was having thank you! it has seemed to uncover another issue though, here is a screenshot of the errors:

Ah, have you enabled Panda3Ds internal physics system? You need to call base.enableParticles() somewhere before setting up the character.

I have done it now, but still the same. I think I have figured it out though. in the is using ``‘base.’’ whereas I am using ‘‘self.’’ I am going to go through the file now and change them see if that works and I will get back to you.

don’t you use showbase to instantiate the engine?

I use super.__init__() as it is what I learned from one of the only panda3D tutorials on youtube. Should I use ShowBase.__init__(self) instead?

I think that shouldn’t make any difference. As long as the super class is initialized and the super class is or contains showbase, then the global variable base should be defined.

Looks like I should have, I changed it over to ShowBase.__init__(self) and it is now working and didn’t have to change from base. , but is stuck in the jumping animation, I’m guessing due to me having a floor with no collider?

I’ll note that if “base” weren’t defined, you should be getting a different error message. Specifically, the interpreter wouldn’t be getting as far as assessing “physicsMgr” and finding it to be “None”–it would presumably be tripping over “base”.

This is now what it looks like:

yeah, if the character won’t land anywhere, it thinks it is falling and hence playing that animation

1 Like