from bge import logic
Collisions = logic.getCurrentController().sensors['Collision']
print('"',logic.getCurrentController().sensors['Collision'].hitMaterial,'"')
but if you were to run this code it would output " ".
I want it to output the material, the face of the object collided, or the colour any one of these would work. Currently as suspected I’m attempting to print out the collided material(s) that is/are hit in the collision. I have checked the type already and yes it is a blank and empty string, this has left me very confused as I do not really understand what the problem is(perhaps just a bug in the bge?).
These aren’t likely of any consequence but my blender version is 2.78, and my setup is:
The collision doesn’t work for me me also, until I switched the sensor option Invert on.
Edit 1:
Still doesn’t work with Python. Only with pure Logic Bricks for some reason.
Edit 2
Ok, work-arounds to detecting materials without material collision.
#Prints MA in-front of the material name to state that it's a material.
logic.getCurrentController().sensors["Collision"].hitObject.meshes[0].materials
that isnt going to work with more than one material.
with upbge, construct bvh from a mesh could help. search through the three, get nearest index to collision point, look at material assigned to poly at index. but outright forget about it in vanilla.
are you by any chance referring to “logic.getCurrentController().sensors[‘Raycast’].hitNormal”
in order to approximate the material based on the objects hit location?
e.g. a polygon proximity check?
I suppose that could work but i feel it’d be slow and inefficient.