a questionin in basic tutorial 2

land

16-03-2008 04:54:10

Hello~ everyone
In the basic tutorial 2, I found out that, the "ent" first was assigned to the Ninja like this:

ent = sceneManager.createEntity('Ninja', 'ninja.mesh')
ent.castShadows = True
sceneManager.rootSceneNode.createChildSceneNode().attachObject(ent)


And then was assigned to the GroundEntity, like this:

ent = sceneManager.createEntity('GroundEntity', 'Ground')
sceneManager.rootSceneNode.createChildSceneNode ().attachObject (ent)
ent.setMaterialName ('Examples/Rockwall')
ent.castShadows = False


Won't it be a problem? the same "ent" was assigned to 2 different things? Or it is ok?

Thanks for replying.

bharling

17-03-2008 11:10:19

Hi again!

no its not a problem, its just a decision not to keep a reference to the entity hanging around. Since its created then attached to sceneNode, theres no reason to keep a reference to it ( ie: self.ent .. ) unless you intend to do something with it later. Usually you would not need to keep references to entities throughout the application, as sceneNodes are what you use to move and rotate objects. However, you may want to keep a reference to an entity for things like skeletal animation.

I agree, its a little confusing, but basically its just using 'ent' as a temporary reference during the creation of entities.

land

17-03-2008 14:55:03

Got it!
Thanks again~
:D