Roaming Ralph Question

Hi,

I managed to make a lot of changes to Roaming Ralph, and everything I broke I managed to fix and make it work the way I wanted so far, but I’m at a point where I’m a bit stymied. How do I get the camera to move more quickly? It automatically follows the floater above Ralph’s head, but when Ralph turns the camera turns rather slower to face the same direction as Ralph. It would seem that:

    self.floater.setPos(self.ralph.getPos())
    self.floater.setZ(self.ralph.getZ() + 2.0)
    base.camera.lookAt(self.floater)

Should be where I am looking, but I cannot seem to find lookAt in the manual to see if there is a parameter or something I can change/add. Another thought I had is that the camera is moving fine, but the floater is orienting to Ralph’s direction slowly, but I could not find a spot in the floater code where the speed was set, only where it sets the x/y/z coordinates. It appears that the elapsed variable (based on the global clock, I believe) is used to impact Ralph’s movement speed and, for the keys to move the camera, the camera movement speed:

    base.camera.lookAt(self.ralph)
    if (self.keyMap["cam-left"]!=0):
        base.camera.setX(base.camera, -(elapsed*20))
    if (self.keyMap["cam-right"]!=0):
        base.camera.setX(base.camera, +(elapsed*20))

But I see no reference to this in the automatic camera orientation code.

Thanks for any information, tips or redirection to appropriate manual pages.

well I don’t think you can make the camera automatically rotate faster just by changing one number, as it is doing its job (following a point above ralph’s head). If what you are thinking of is a camera that is always behind ralph, and is slightly springy, check this out:

discourse.panda3d.org/viewtopic … ht=springy

or you could just set the H of the camera to the same as Ralph’s using a interval, like:

LerpHprInterval(base.camera, <speed>, Point3(self.ralph.getH(), base.camera.getP(), base.camera.getR())).start()

or you could write a task to do it. In fact the possibilities are endless :slight_smile:

Ah, I see, since it is following a point it has no real reference of which way Ralph is facing, it just turns to follow the point, which has no “front”. I’m not sure what the H is, but I’ll go look at the LerpHprInterval and figure it out. Thanks, you gave me a good direction to start sniffing in.

H is the Heading. meaning the part of the rotation which would spin him around his own vertical axis.

P would be pitch and R would be roll.

You’re welcome :slight_smile:
H is also known as “Yaw” in some places

Thanks again, though the LerpHprInterval gave me problems (it faced away from Ralph, and from other problems people had which I found by searching the forums I wonder if Ralph’s model is backwards), it occurred to me that I was making something relatively simple complicated, so I just changed this:

        # If a move-key is pressed, move ralph in the specified direction.

        if (self.keyMap["left"]!=0):
            self.ralph.setH(self.ralph.getH() + elapsed*300)
        if (self.keyMap["right"]!=0):
            self.ralph.setH(self.ralph.getH() - elapsed*300)
        if (self.keyMap["forward"]!=0):
            self.ralph.setY(self.ralph, -(elapsed*25))
        if (self.keyMap["backward"]!=0):
            self.ralph.setY(self.ralph, +(elapsed*10))

To This:

        # If a move-key is pressed, move ralph in the specified direction and pan camera to follow.

        if (self.keyMap["left"]!=0):
            self.ralph.setH(self.ralph.getH() + elapsed*300)
            base.camera.setX(base.camera, +(elapsed*45))
        if (self.keyMap["right"]!=0):
            self.ralph.setH(self.ralph.getH() - elapsed*300)
            base.camera.setX(base.camera, -(elapsed*45))
        if (self.keyMap["forward"]!=0):
            self.ralph.setY(self.ralph, -(elapsed*25))
        if (self.keyMap["backward"]!=0):
            self.ralph.setY(self.ralph, +(elapsed*10))

Which seems to work well for my purposes. The Lerp functions you pointed out are extremely interesting, my only problem now is that I’m having too much fun lerping things! :smiley: