Jump to content

Recommended Posts

Posted

I have a simple script like the one below applied to a Pivot. I've dragged my player entity into the "Target" property. When the Start function is called it prints out "target=nil". If I drag some other entity into the Target property I get something like "target=userdata: 0x04245938", which is what I was expecting when my Target is Player. Is there something special about the Player entity?

 

 

Script.target = nil --Entity "Target"

function Script:Start()
  System:Print("target="..tostring(self.target))
end

Posted

I've not decided what this means yet but I've modified my Start function to search for the player entity. It finds it! So I know the player entity exists at the time Start is executed.

 

function Script:Start()
 System:Print("target="..tostring(self.target))

 for x=0,App.world:CountEntities()-1 do
   local entity = App.world:GetEntity(x)
   if entity:GetKeyValue("name") == "Player" then
     System:Print("entity="..tostring(entity))
   end
 end
end

Posted

And what is Player? Is it the player prefab or something different? Are you able to reproduce this isolated case in another test project? Have you removed and readded Player in the script tab?

Posted

The player is the prefab that comes with LE(although I did add a weapon). I have deleted the pivot and created a new one then added the script.

 

Thinking about all this, I tried deleting the player entity from the scene and re-adding it. This cleared up the issue! I guess I should have tried that hours earlier.

 

Thanks again

Posted

Clearly an LE bug. Did you happen to save the map file that has this bug so you could give it to Josh in a bug report? This shouldn't happen and he can examine the map file further to see why it did.

Posted

Hi,

 

i had this aso after the Beta Update with an lua script targeting a camera.

Removing the script saving and rebuild the dependencies of the scrpt after reload solved this.

 

cu

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.

×
×
  • Create New...