Jump to content

bug in GoToPoint example


Recommended Posts

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitygotopoint-r700

 

self.world:BuildNavMesh() instead of world:BuildNavMesh()

 

function App:Start()

--Create a window

self.window = Window:Create()

self.context = Context:Create(self.window)

self.world = World:Create()

local camera = Camera:Create()

camera:SetRotation(35,0,0)

camera:Move(0,0,-8)

local light = DirectionalLight:Create()

light:SetRotation(35,35,0)

 

--Enable navmesh debugging

camera:SetDebugNavigationMode(true)

 

--Create the ground

local ground = Model:Box(10,1,10)

ground:SetPosition(0,-0.5,0)

ground:SetColor(0.0,0.25,0.0)

 

--Create a shape

local shape = Shape:Box(0,0,0, 0,0,0, 10,1,10)

ground:SetShape(shape)

shape:Release()

 

--Create a model

--This is an obstacle the player will walk around

self.entity = Model:Box(1,1,3)

self.entity:SetColor(0.0,0.0,1.0)

self.entity:SetPosition(0,0.5,0)

 

--Create a shape

local shape = Shape:Box(0,0,0,0,0,0,1,1,3)

self.entity:SetShape(shape)

shape:Release()

 

--Enable navigation obstacles

ground:SetNavigationMode(true)

self.entity:SetNavigationMode(true)

 

--Build the navigation mesh

self.world:BuildNavMesh()

 

--Create a character

self.player = Pivot:Create()

local visiblecapsule = Model:Cylinder(16,self.player)

visiblecapsule:SetScale(1,2,1)

visiblecapsule:SetPosition(0,1,0)

self.player:SetPosition(-4,0,0)

self.player:SetMass(1)

self.player:SetPhysicsMode(Entity.CharacterPhysics)

 

return true

end

 

function App:Loop()

 

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

 

if (self.player) then self.player:GoToPoint(4,0,0,1.4,1) end

 

Time:Update()

self.world:Update()

self.world:Render()

 

self.context:SetBlendMode(Blend.Alpha)

self.context:DrawText("NavMode: ".. tostring(self.entity:GetNavigationMode()),2,2)

 

self.context:Sync()

 

return true

end

It doesn´t work... why? mhmmm It works... why?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...