rayCast() Returns None for Poly

I have the physics for my target object set to Static with Convex Hull selected for the collision bounds. I get the object, hit position and normal position, but poly returns as type none. The documentation simply states it needs to be of Static type and valid, whatever “valid” means. My script is as such:


import bge


logic = bge.logic
controller = logic.getCurrentController()
own = controller.owner
scene = logic.getCurrentScene()
ob_list = scene.objects


ground = ob_list["Plane"]


hit = own.rayCast(ground, own, 0.0, "ground", 0, 1, 1)
print(hit)

testraycast.blend (511 KB)

Poly proxy only works with triangle mesh*

Just tried changing it to all tris instead of quads and Triangle Mesh collision bounds. Returns None for everything now. I’m not sure where you read that (I can’t find it anywhere), but I’ve used polys with non-triangle mesh physics before.

I mean the physics type*

can I see a .blend?

code snippet

edit: looked at top post

first argument needs to be a vector* and second

ground.worldPosition, own.worldPosition

The raycast is going through fine. It returns hit and normal vectors, it returns the object hit. But Poly returns as None. I tried changing it to ground.worldPosition and own.worldPosition, and I get the same result.

Posting .blend in top post.

ok, it was not set to triangle mesh, and your ray was not hitting the target

added render.drawline so you can see what is going on.

Attachments

testraycastBPRReturn.blend (511 KB)

I had reset my settings back to what I’d originally started with, to make sure I wasn’t leaving something erroneous. Was that all you changed?

mesh = triangle mesh physics type

drawline = see ray and make sure it crosses through plane

used own.worldPosition+own.worldOrientation.col[2]*10 as ray end point (a point -10 units under your raycaster local)

Yeah, I meant the physics simulation thing. Man, I swear, I tried it. And it gave me None for all results. I dunno if I was rushing and maybe hit something else? I have no idea. I feel bad, now. :stuck_out_tongue:

On another note, I feel like I keep seeing stuff I can’t find any reference for. Such as worldOrientation.col. I looked in the documentation and can’t find where that exists. There’s just a ton of options for xyz stuff. Same thing with wherever you found that it only works with triangle mesh physics. Am I reading the wrong stuff? https://www.blender.org/api/blender_python_api_2_69_1/bge.types.KX_PolyProxy.html That’s 2.69, (most popular on Google, I guess), but it’s not so old it should be that out of date.

Object.worldOrientation.col[0] = local x+ axis

Object.worldOrientation.col[1] = object local y axis

Object.worldOrientation.col[2] = object.local z axis

Oh. Hah. Had to follow one more link. https://www.blender.org/api/blender_python_api_2_66_4/mathutils.html#mathutils.Matrix

Thanks man. I appreciate the help.