my FPS script awsd+jumping wall sliding

This is the best example I’ve seen so far with simple gravity and movement! Thanks for posting this!

You welcome.

really useful for learning.
however, the github version is not available, could you post a link to the current version?
I do want to use it for learning and I’d post any improvements back, of course…

Sorry the link was broken ( I think it was a my private link )

here is the new one
http://github.com/treeform/simple-fps

The gravity is still weird, especially walking down a ramp.

I’ve been trying to adapt the jumping functionality from treeform’s version, but I keep getting an error:

AttributeError: World instance has no attribute ‘setattr

The code I am using is:

        self.accept("e", self.__setattr__,["jump",1.])

[...]

 #==========

        #This is supposed to enable jumping.

        highestZ = -100
        for i in range(self.actorJumpHandler.getNumEntries()):
            entry = self.actorJumpHandler.getEntry(i)
            if (entry.getIntoNode().getName() == "terrain") or (entry.getIntoNode().getName() == "floodcollider"):
                z = entry.getSurfacePoint(render).getZ()
                if z > highestZ:
                    highestZ = z
        # graity
        self.actor.setZ(self.actor.getZ()+self.jump*globalClock.getDt())
        self.jump -= 1*globalClock.getDt()
       
        if highestZ > self.actor.getZ()-.3:
            self.jump = 0
            self.actor.setZ(highestZ+.3)

I don’t see setattr being defined anywhere in treeform’s code, or in ynjh_jo’s for that matter. What’s up with this? This is not the first time I’ve tried to use code seen in other programs and gotten a seemingly inexplicable attribute error.

I tried turning the jumping into a function to be called by a key press, but whenever I press the jump key, the actor moves a tiny, tiny amount upwards, and stays there, not moving downwards after that. Here is the modified function:

    def jumpActor(self):
        self.jump = 1
        highestZ = -100
        for i in range(self.actorJumpHandler.getNumEntries()):
            entry = self.actorJumpHandler.getEntry(i)
            if (entry.getIntoNode().getName() == "terrain") or (entry.getIntoNode().getName() == "floodcollider"):
                z = entry.getSurfacePoint(render).getZ()
                if z > highestZ:
                    highestZ = z
        # graity
        self.actor.setZ(self.actor.getZ()+self.jump*globalClock.getDt())
        self.jump -= 1*globalClock.getDt()
       
        if highestZ > self.actor.getZ()-.3:
            self.jump = 0
            self.actor.setZ(highestZ+.3)

        self.cTrav.traverse(render)

I’ve also tried it by removing all references to self.jump, but this has the same result.

Make your World class derive from ‘object’ to make it a new-style Python class, which should have setattr.

Ah, that would explain a lot. Thanks!

Should probably updates this with real gravity and better level model and no setattr. Some one make me do it!

I just wanted to write and thank you for including a simple FPS framework for me to start off with. I am thinking of using Panda3D for my game development degree capstone project and this should get me off to a good start. The only thing I hate about panda is that there is no easy way for linux people to get their art assets into panda. I have tried chicken in blender 2.49 and it just doesn’t work. All the other tools to get assets into panda for linux isn’t for linux. Even the Level editor doesn’t work easily.

It’s not true… I use Linux and Chicken, I export models without problems… I’ve a simple Ubuntu installation.

The level editor was a summer CMU project, I haven’t seen updates on it after that. But Blender is a complete level editor, and it’s well-integrated with Panda (or, if you target FPSs specifically, you could use specific map editors (I used to use GtkRadiant and QuArK) and write some importers - something like this).

Do you plan on updating this tutorial?