- Code: Select all
obj = 0;
-- System initialisation - Skyline script entry point
function onInit(objID)
sky.lprint("LUA: Script Active!");
obj = objID;
end
-- Called after all the scenes onInit() have been called.If you need to ensure your data exits, then do you set up here
function postInit()
navmesh.addEntity(obj);
navmesh.showAgentDebug(obj,1);
navmesh.setAgentMaxSpeed(obj, 10);
local pos = newType.vec3(entity.getPosition(entity.getIDFromTag("Player"));
navmesh.setDestination(obj, pos.x,pos.y,pos.z);
end
-- Updated every frame
function onUpdate(timeDelta)
if (navmesh.isDestinationReached(obj)==1) then
navmesh.setAgentControlled(obj,0);
end
end
Navmesh is generated.
Player character has tag "Player", running the game the npc doesn't move.