Yes using the API https://api.aurasoft-skyline.co.uk/annotated.html you can even preload presets etc.
the way I personally would go about this is.- Import your model and assign animations etc.
- Add a controller by script or via the actions editor (I think the Dynamic controller is the best (my personal option) https://api.aurasoft-skyline.co.uk/classcontroller.html).
- Save the char with controller etc as a preset (for this example I used player1 as the filename).
Now you are ready to bring it into the scene via script.- Code: Select all
SpawnID = entity.spawnPreset ("player1",posx,posy,-100,1,1,1);
Now set the Tag of the player brought into the scene so you can reference it via a known tag in other scripts etc.- Code: Select all
entity.setTag(SpawnID,"Player");
You can also Preload mesh and presets so they do not pop in etcYou can use the resource.preparePreset("preset to load in") command
one of the uses for this could be via scene script.
- Code: Select all
obj = 0;
function onInit(objID)
obj = objID;
resource.preparePreset("Player1");
end
A bit extraDoes entity already exist?You could also run a check to see if the preset brought in exists in scene already before spawning the player etc in using the following command(s).
In the init section of the script that brings in the player preset,this will make the preset initially spawn and is good practice to declare the variable even though you do not have to in LUA.
- Code: Select all
SpawnID = 0;
Check and spawn preset.- Code: Select all
if( entity.exist(SpawnID) == 0 ) then
SpawnID = entity.spawnPreset ("player1",posx,posy,-100,1,1,1);
entity.setTag(SpawnID,"Player");
end
OR- Code: Select all
if( entity.exist(entity.getIDFromTag("Player");) == 0 ) then
SpawnID = entity.spawnPreset ("player1",posx,posy,-100,1,1,1);
entity.setTag(SpawnID,"Player");
end
Hope this helps..