Closed GORILLASTIXS closed 2 years ago
Hi, if you could give me a few more details, I'll try to help you find the problems source. First of, which operating system are you on, which version of panda3d and python do you use and is your mouse cursor catched within the window. Also check if the camera stops spinning if you pause the demo and then unpause it again (press P twice). Finally, does this only happen in one camera mode for example third person mode or is it applicable for both, third and first person?
Thank you for getting back to me! My OS is Ubuntu 20.04.3 LTS and python 3.8 as the interpreter. This occurs the moment I run the demo, which I downloaded as a zip. When I press F2, the camera is stable and allows me to control the fox in first person camera.
Stays the camera stable if you press F2 to get back to third person mode again?
Maybe this is some kind of bug at the initialization. Can you check where your mouse pointer is at the time you start the application and does the spinning change if you move your mouse?
It goes back to the glitch right after I press F2 again. My mouse can be seen before the game starts and pauses. Moving the mouse affects the direction of the camera slightly but it reverts back immediately to that state.
ok, few more things to check.
print(mw.getMouse())
This will print the mouse position every frame. If you haven't moved your mouse, this should always be 0,0
if cam_left
and elif cam_right
in the same file add a print statement to see if any of the two is activeThose should be the only places in which the camera gets moved horizontally, except for the collision detection, but I guess one of those could cause the problem.
After following these instructions, these are the values that I am getting from the print statements. These are outputs without moving the mouse.
ok, somethings definitely off with your mouse position. Can you now print the value of the following self.core.getConfig("win_width_half")
This should represent the width of your window divided by 2. From what I see I think your window is 800x600 so this should read 400.
I added that print statements to various functions, got a couple errors. I then commented some of the print statements out and left one under def pauseCamera(self). This stabilized my camera. My values print out to LPoint2f(0,0), as opposed to the image before. Would you happen to know if this is a valid solution or if the code would be prone to breaking in future events?
Print statement: print(self.core.getConfig("win_width_half" + "pause camera"))
LPoint Values:
That shouldn't make any difference at all since it's only called if you pause the player in first person mode and also will it break the pause for first person mode since you try to access a configuration that doesn't exist.
Is that the only change left in your code by now or are there changes in other files?
I haven't changed anything since I cloned this repo. The problem seems to occur when I enter into full screen. When I minimize the window, the code works fine.
Ah, can you check if the window size given with base.win.getSize() in fullscreen is the same as when it's windowed?
How would I go about doing this?
These are the only instances where I see base.win.getSize():
1). base.win.movePointer(0, base.win.getXSize() // 2, base.win.getYSize() // 2)
2). def togglePause(self): """This function shows how the app can pause and resume the player""" if self.pause:
_**self.playerController.win_width_half = base.win.getXSize() // 2**_
**_self.playerController.win_height_half = base.win.getYSize() // 2_**
Just add a print(base.win.getSize())
somewhere. Shouldn't matter much where. You can for example add it in the task where you have printed the mouse position previously.
I just need the output once at Fullscreen and once from Windowed mode.
LVecBase2i(840, 704) - Regular LVecBase2i(1294, 704) - Fullscreen
Hm, strange values for a fullscreen resolution. Are those correct for you screen and window?
Ah, another thing you can try is copying the following code to set the half window size variables in the task where the camera gets updated, just somewhere at the start like, at the place you added the first print statement.
self.core.setConfig("win_width_half", base.win.getXSize() // 2)
self.core.setConfig("win_height_half", base.win.getYSize() // 2)
I added both statements under the thirdPersonCam pauseCamera function. When I run the code, the camera still glitches, but when I then pause the camera, that stabilizes is the scene without any glitch.
Once I moved the XSize and YSize to updateCamera instead of pauseCamera, the code ran without any issues. Thank you for the help!
hm, ok. May you send me the changed files so I can have a look at them? I'm still wondering how this can happen.
Not sure why this fixed it, but whenever I comment out the two statements the code bugs outs. Doing the opposite allows the code to run properly. How would you like me to send the code? Copy and paste? Screenshot? Email?
Just paste the files here or as a gist https://gist.github.com/ would be fine.
@Haitianwarrior do you still have the changes and would be so kind to send them to me? Otherwise I'll close this issue for now.
Hello Sir,
Thank you for this very helpful and applicable tutorial. I want to get going on a project by using some of these templates. As I start the demo.py code, the camera rotates around uncontrollably. Could you please help me? I've been up all day trying to figure it out. Any tips would be great. Thanks again!