Alright, so the title mostly explains the problem. But let me explain what I’ve done to try and solve this, and what more I want.
Using Python I want to cast a ray along the Z-axis to detect a property named ‘ground’ below the player. If it’s above the player, they can pass right through it. I know I can set the player to rest upon a plane with the ‘ground’ property without falling by using worldLinearVelocity.z = 0 and then set the max velocity when they’re falling. So that’s not a problem.
The problem comes when I’m trying to get the game to recognize the rayCast in the first place. After reading through all the documentation for every version of 2.7, using Wayback Machine to access TutoritalsForBlender3D.com, and searching through both here and StackExchange, I still can’t figure out how to make rayCast cast along that single axis in a single direction. The code I tried detects the ground object regardless of orientation, and doesn’t deactivate when it’s no longer near the planes with the ‘ground’ property. It’s as follows:
blah blah blah import BGE and list the scene objects whatever, we all know this rayToGround = playerA.rayCast((0.0, 0.0, 0.0), None, -0.01, 'ground', 0, 0, 0) if rayToGround is not None: own['isOnGroundYesEdBoy'] = True print("The player's head ain't in the clouds for once") else: own['isOnGroundYesEdBoy'] = False print("Hope that fall doesn't break their legs...")
And even if the player character is in the middle of the air it still prints only that first statement and keeps the boolean property true. All because it’s detecting across all axes and then not deactivating when it’s nowhere near what it’s supposed to detect. Driving me nuts.