first of all, I have to say, that I have only understand the basics of python, or better : I understand already written code quite good, but I can’t “learn” from it.
So, for a school project I wanted to recreate super mario bros.
Now, I found a script of Solar Lune (thanks to you, if you read this).
The code parts for walking left and right were already implemented, but I have to make mario jump of course.
I asked Solar Lune, and he told me, using something like
If the spacebar is pressend and character stands on ground
He also suggested to use the raycast() function.
Now comes the problem: I dont really understand how I have to use it.
What I wrote :
from bge import logicimport GameLogic cont = logic.getCurrentController() obj = cont.owner pos = obj.position # Get the Player's current position topos = pos.copy() # Make a copy of the Player's current position scn = GameLogic.getCurrentScene() obj1 = scn.objects["cube"] pos1 = obj1.position if obj.rayCast(pos1, pos, 0, "wall", 1, 1) != None : print("Hit") else: print("Not hit")
In my scene, there is a cube, which has the property “wall” , and I have the cube which has the script assigned.
The “wall cube” just stands there, does nothing else.
The other cube is ‘Dynamic’ and placed above the "Wall"Cube.
What should happen, is while the cube is falling, it should print “Not Hit”, and as soon as it fell on the wallcube, it should print “Hit” (I think you get what I want to do)
Could maybe someone show me an example of how it should be written (It doesn’t have to be the exact solution, maybe I can learn just by an example)
Wow… a lot of text about a small problem But I cant explain good ^^
Anyways, if you could help me, I of course would appreciate it.
PS: If something is unclear, please just ask