cube = scene.objects['cube']
class cubeitem:
def __init__(self, ammo):
self.ammo = 10
cubeitem = cubeitem(10)
if click.positive:
print(obj.meshes)
if obj.meshes == cube:
print(cubeitem.ammo)
until the second if, the code works fine, it prints the objects mesh (which can change in the game) as [cube], yet the second if statement does not run, even when the conditions are theoretically correct.
what am I doing wrong? why won’t the second if statement work?
I think obj.meshes returns a list of the meshes on a game object.
I hope you know what is the difference between game object and mesh.
If you have two cube meshes in your game object, then you should use
obj.meshes[0] for the cube with idx 0 and obj.meshes[1] for the cube mesh with idx 1
You can not access a mesh in a game object with a name(because meshes have no names, only the mesh group have name) but only with its index.