Recently i’ve been learning python, i’ve followed this tutorial http://solarlune-gameup.blogspot.com/search/label/BGE%20Tutorials and like many other tutorials it tells you a simple way to set up a ray and pretty much make you stop if it detects something in the ray. however although this works okay for some things, it dosn’t work as well as i would like. you see if you use a ray it just pretty much sends a straight line from the center of your object, but for example lets say you move up into a wall, when you reach the wall you would stop, however lets say if your moving up and theirs a wall slightly to the left, well then your ray wouldn’t detect the wall and part of your object would pass through the wall, which dosn’t look too good.
Let the physics do the job. It collides with the walls and prevents to slide through them (as long you do not use small and fast objects).
A ray is a ray. It is like walking through your appartment with eyes closed and trying to find a way by holding your arm forward, touching for obstactles. ;).
well, i’m trying to learn python, although many things such as physics work to a degree, it usually dosn’t give you as much control as python.
Hey, that’s my tutorial! You are correct that the rayCast functions are just single rays. I also prefer to use Python instead of physics, though using the Bullet physics engine for movement is useful for certain movements that are tough to do in Python.
You could use the Bullet collision system in conjunction with ray functions, or, alternatively, shoot two or more rays from each side of the object forward.
yea i was thinking about shooting more rays frome the sides, is it possible to send rays from the sides without creating more objects?? it seems to me that rays are sent from the center of the object, is there a way to offset it? by the way that was a great tutorial, i went ahead and even added some gravity, a jump system, and if you jump on the enemys head you can kill it.
well generally you don’t need the additional rays, you can set it up with one ray sensor that points forward’s, what you need to do is find the distance of the ray you need for the object your shooting (the higher the velocity the longer the ray needs to be).
@LightBulb - Nice. Yeah, you can offset ray cast functions by changing the ray’s origin property, like this:
origin = obj.position.copy() origin.x -= 1 topos = origin.position.copy() topos.y += 1 ray = obj.rayCast(topos, origin, etc.) origin = obj.position.copy() origin.x += 1 topos = origin.position.copy() topos.y += 1 ray = obj.rayCast(topos, origin, etc.)
okay thanks thats exactly what i was looking for, i actually was just thinking about doing something like that before i read this.
No problem. Definitely, certain game designs need Bullet to work, like racing games. However, certain times you want exact physics capabilities that can only be achieved with Python (a top-down RPG game, for example).