New Guy in Town [Might need some help later on!]

Hey, guys. So I probably spent the last 3 months learning and coding in python. I had my teacher give us a taste of PyGame, and I thought it was pretty cool. I have a grasp of all the basic concepts of Python using PyGame, but I wanted something more personal, so I found Panda3D. This is totally new to me, programming for 3D games, and using no visual level editor, so it will take a lot to get used to. The concepts are totally different, but it’s comforting to see the core Python usage in everyone’s code. I don’t really know how this community works, and if you’re used to having new guys around, then I’m happy about that. If you aren’t used to having a new guy around, just let me know and I’ll find another community!

So far, though, after looking at various codes, I’ve been able to take the Roaming Ralph, and transform it into a Roaming Ralph with WASD movement controls, as well as jumping. However, when I jump, the collision detection is still running, so I cannot hop over any objects. Any suggestions as to what I can do? Set a variable that will determine whether I’m in the air or not, and if I’m in the air, then disable the collision detection? Thanks so much for anyone’s input!

Hey, welcome to the forums! :slight_smile:

Perhaps you are raising the character without raising the CollisionRay object? You should call show() on the ray’s NodePath to enable its debug visualisation, so that you can verify if this is indeed the case.

You shouldn’t disable the collision detection when in air, because it’s the collision detection that will tell you when you’re touching the ground again. :wink:

That makes absolute sense! Good call on that one, aha! So, I checked out the visuals, and, indeed, the CollisionRay is not moving upwards as my character moves upwards. Now, can I easily just:

self.**Insert Collision Ray**.reparentTo(jumpingRalph.node)

Or will that not necessarily work? Obviously, I’d use the object, not what I literally wrote above.

I created a jumping class above my main class:

class Jumper(object):
	def __init__(self): = DirectObject()
		self.node = NodePath("jumpingRalph")
		self.duration = 0.5
		self.height = 3.0
		up = LerpPosInterval(self.node,
		down = LerpPosInterval(self.node,
		self.s = Sequence(up, down)"space", self.runSequence)
	def runSequence(self):
		if not self.s.isPlaying():

Or am I missing a few steps? Basically, all I am asking is, do I have to add one line of code where I make the Collision Ray reparent to my JumpingNode. And by doing this, my Collision Ray should jump up with my character?

This is what my code looks like with the jumpable character, but with no collision being raised with it.

#Jumping Test
		jumpingRalph = Jumper()

Please, I’m not asking for the code solution. I know it may be hard to not give the answer right away, and I respect that; but I would appreciate any help that is given. Thanks so much for your time!

EDIT I tried this code:


Immediately, I start much higher, and I stay there. I can still move around and jump and everything, but it bugs out hard core. What happens is right from the start I start at a higher point. Almost as if the floor had been raised, yet the world stayed at the same fixed position. I could walk through all the hills and rocks and everything. The map I’m using is from Roaming Ralph.

That’s probably because the collision code in Roaming Ralph updates the Z position of self.ralph assuming that it was reparented to render (it does getSurfacePoint(render) to get the position relative to render but then sets the Z position of self.ralph relative to its parent node, which isn’t render, so that’s a coordinate system mismatch).
Perhaps you should make the collision code adjust the Z of jumpingRalph.node instead of self.ralph (if you do so, you’ll also need to adjust it to assign the start_point position to jumpingRalph.node instead of self.ralph as well).

Perhaps a slightly easier solution is to make your Jumper class work with the existing node instead of creating a new node, by allowing yourself to pass a parameter to it, namely self.ralph. Either method should work fine, though.