Roaming Ralph (Position Ralph+Collsion)

i want to understand “Roaming Ralph” from the sample scripts: -> where can i change the hight of the model “Ralph”?
(i changed the model with my own model, but i can see only have of it, rest is below ground: how can i add +5 or something like that to the z-level?) thx

Look, I have made an example of ralph in a simple way which it is also able to jump (without using gravity physics)
by pressing “A” button and there you will be able to change the Z value of it too

I removed the unimportant codes, and also I removed the codes of collision with trees and rocks (that will make ralph go over the tree) but you can take it from the original code
http://www.mediafire.com/file/dl7d0377lb9x494/ralph-jump.zip

Ralph’s origin is at his feet, so if you don’t want to change it by code, shift your model’s origin to its feet (in the modeler).

thx, model is now in the right position. :slight_smile:

+new question in my learning progress:
how can i change the model “world” /how do i have to export it in blender/chicken export, so that it work with collision dedection correctly?
-> it’s not working/i get the following error-message:

start_point is an empty node, serves as Ralph spawn position.

and if you want to replace the terrain, you either have to create an empty node called “start_point” in your modeleditor. or you change the line of code which puts ralph there and hard-code it to some value.

you may also need to change the collision flag in your resulting egg file. [Ralph not Moving)

thx! now it seems to work: can see ralph+terrain+ralph is walking, yatta!:slight_smile:

found the solution in:
bcchang.com/immersive_blog/?p=561

→ you have to add:

  • AND change the name to “terrain” in your .egg file:

→ how can i now add objects, where ralph can’t walk through (like the trees in the original sample)/collision detection? thx

the download link is dead, could u post a new one plz? thx

[code]
Hi!

I am struggling with this problem from 2 days. please help :slight_smile:

I am changing the Roaming Ralph code by adding my own model which is an Astronaut (named ‘astro’).
I now need to test it for collision with other objects which I have introduced in the world.(say a ‘rover’)
So basically i am checking (astro-into-rover)

I added a collision sphere on asto and on the rover. but still I am not able to detect collisions.
I have pasted the imp parts of code for reference:


        self.rover = loader.loadModel("models/more/rover/rover")      
        self.rover.reparentTo(render)
        self.rover.setPos(-114,8,0.5)
        self.rover.setHpr(219.29,354.810,351.87)
        self.rover.setScale(.04)
		
        self.cNode = CollisionNode('rover')
        self.cNode.addSolid(CollisionSphere(0,0,0,80))
        self.roverC =          self.rover.attachNewNode(self.cNode)


self.astroGroundRay = CollisionRay()
        self.astroGroundRay.setOrigin(0,0,1000)
        self.astroGroundRay.setDirection(0,0,-1)
		
        self.astroGroundCol = CollisionNode('astroRay')
        self.astroGroundCol.addSolid(self.astroGroundRay)
        self.astroGroundCol.addSolid(CollisionSphere(0,0,100,50)) 
        self.astroGroundCol.setFromCollideMask(BitMask32.bit(1))
        self.astroGroundCol.setIntoCollideMask(BitMask32.allOff())
        self.astroGroundColNp = self.astro.attachNewNode(self.astroGroundCol)
        
        self.astroGroundHandler = CollisionHandlerQueue()
        self.cTrav.addCollider(self.astroGroundColNp, self.astroGroundHandler)
        self.astroGroundColNp.show()


self.accept( 'into-self.rover' ,self.collide1)

def collide1 (self,collEntry):
		print ("collision!")

collision detection setup always makes me have to think hard so this is only a half-baked suggestion …

  • what about the into mask on rover?
  • did you make a CollisionHandlerEvent() ?