Jump to content

navigation functions


xtreampb
 Share

Recommended Posts

So I just frustratingly figured out that if you wrap the entity navigation functions in an if check (in lua) then the actual movement doesn't happen if it results to true. It would be nice to denote this in the API documentation. I'll put a comment in there for future reference.

bool Life()
{
 while(death=false)
 {
   if(death==true)
   return death;
 }
}

 

I have found the secret to infinite life

 

Did I help you out? Like my post!

Link to comment
Share on other sites

So I just frustratingly figured out that if you wrap the entity navigation functions in an if check (in lua) then the actual movement doesn't happen if it results to true. It would be nice to denote this in the API documentation. I'll put a comment in there for future reference.

 

Are you sure? because I just used the default example code and used the exact code you said didn't work and the player moved.

window = Window:Create()

context = Context:Create(window)

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)

camera:SetDebugNavigationMode(true)

 

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

ground:SetPosition(0,-0.5,0)

ground:SetColor(0.0,0.25,0.0)

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

ground:SetShape(shape)

shape:Release()

 

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

entity:SetColor(0.0,0.0,1.0)

entity:SetPosition(0,0.5,0)

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

entity:SetShape(shape)

shape:Release()

ground:SetNavigationMode(true)

entity:SetNavigationMode(true)

 

world:BuildNavMesh()

 

player = Pivot:Create()

local visiblecapsule = Model:Cylinder(16,player)

visiblecapsule:SetScale(1,2,1)

visiblecapsule:SetPosition(0,1,0)

player:SetPosition(-4,0,0)

player:SetMass(1)

player:SetPhysicsMode(Entity.CharacterPhysics)

 

while window:KeyHit(Key.Escape)==false do

if window:Closed() then break end

 

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

end

 

Time:Update()

world:Update()

world:Render()

 

context:SetBlendMode(Blend.Alpha)

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

context:Sync()

end

 

Also, the example code you posted for Entity:Follow() is the incorrect syntax - so maybe thats why it didn't work?

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

The gotopoint function returns weather or not you can reach the point, so you have to actually call the command again to start moving

 

Not from what I am seeing. Just one call to it will make the entity move if the point can actually be reached.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

if player:GoToPoint(x,y,z) then

end

 

This means can the player reach the point, yes or no. It doesn't tell the player to actually go there though.

Did you actually try the example script i posted? You can even take that code out of the main loop and the player will still move to the point if it can be reached. Whether you think this is wrong is another discussion.

 

You are saying it shouldn't move the entity but only state if the point can be reached and the OP is saying that it should move the entity but doesn't. The example code shows that it does make the player move to the point if reachable even if its in a if/then statement. Unless there is a difference in versions (I am using the beta) that everyone is using and some fundamental thing has changed, then any use of this command that returns true will make the entity move to that point.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...