0
$\begingroup$

For defining objects, the usual scene.objects["obj"] works. I am trying to do the same concept but with a mesh. How can this be done?

$\endgroup$
1
$\begingroup$

Following my previous answer here, you want to get the mesh (one of them), not define it. To do that you should use obj.meshes[0] (since usually there is only one mesh).

You can find the BGE API here. Of particular interest is the KX_GameObject class, where most of BGE coding is actually done.

$\endgroup$
  • $\begingroup$ Thanks for the answer. Also, will it work if I define this: obj.meshes[0]? You stated to call it, not define it. If I will use it a whole lot, will it be fine if I define it or will it just not work? And how can an object have 2 meshes? If I change the mesh of an object, does that mean there is a new mesh? $\endgroup$ – blackhole Jan 5 '16 at 2:40
  • $\begingroup$ An object can have a display mesh and a physics mesh. But this is not what it provides. KX_GameObject.meshes provides display meshes only. I never saw an object with more than one mesh. $\endgroup$ – Monster Jan 5 '16 at 7:57
  • $\begingroup$ You can store the mesh in a variable for local use (mesh = object.meshes[0]). But I strongly advice to avoid to store context data (such as current scene, current controller, current object and current objects mesh) outside the context (e.g. at module level or a property of another object). This will result in hard to investigate side-effects. $\endgroup$ – Monster Jan 5 '16 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.