For a mod I'm working on I would like to instantiate a character like a farmer or eventually a pedestrian.
I'm trying to use this kind of code but without great result
Code: Select all
self.x, self.y, self.z = getWorldTranslation(g_currentMission.player.rootNode);
self.dx, self.dy, self.dz = localDirectionToWorld(g_currentMission.player.rootNode, 0, 0, 1);
self.rotY = 0.73;
self.x = self.x + (0.5 * index)
-- Tests using one of these 3 i3d
sceneToLoad = Utils.loadSharedI3DFile("character/player/player01.i3d","dataS2/",false,false, true);
--sceneToLoad = Utils.loadSharedI3DFile("character/pedestrians/pigLoaded.i3d","dataS2/",false,false, true);
--sceneToLoad = Utils.loadSharedI3DFile("character/pedestrians/man01.i3d","dataS2/",false,false, true);
self.farmerId = getChildAt( sceneToLoad, 0)
if self.farmerId ~= nil then
link(getRootNode(), self.farmerId)
print("this is the farmerId: ".. self.farmerId) -- shows me an id
setVisibility(self.farmerId, true)
setTranslation(self.farmerId, self.x, self.y + 1, self.z)
--setRotation(self.farmerId, self.dx, self.dy, self.dz);
--setScale(farmerId, 5, 5, 5)
else
print("this is the farmerId: nil") -- shows me nil
end
Is there something special to do to load an animated i3d or another way to do so ?
Thanks for your answer.
EDIT:
I got answer from another forum to take a look at "Oxygendavid's" map Sandy Bay map. There are different pedestrians loaded by specific lua script. And it works ! at least I see pedestrian standing.
Now will try to make them move a little bit (without a spline)