Search the Community
Showing results for tags 'nil'.
The search index is currently processing. Current results may not be complete.
-
scripts/objects/ai/monsterai.lua" : 143 : attempt to call method 'GetPosition' (a nil value) I get this error whenever i spawn a crawler into the map by code (not drag & drop). It is the default script and it works when i drag the prefab into the scene. The following happens: Crawlers begin to run towards player. Error comes up. (all in all <1 second). I have no Idea why this isnt working. In case heres a download link: http://www.mediafire.com/download/13drm2j8i14ydin/SlastrafProject.rar its the start map which is not loaded by default i think ( in my project) . The self.Target is assigned (target = player) trought the script and everything else is not missed out.
-
This is my code: DeathTrigger.lua (attached to a box) Script.respawnPoint = "" --Entity "respawn point" function Script:Collision(entity, position, normal, speed) if(entity:GetKeyValue("name") == "Player") then spawnPos = self.respawnPoint:GetPosition() --entity:SetPosition(spawnPos) entity:Respawn(spawnPos) end end and FPSPlayer.lua (attached to the player) function Script:Respawn(spawnPos) self.entity:SetPosition(spawnPos) end When they collision I get this error: I have a Pivot indicating the respawn point: Line 65 is this from DeathTrigger.lua: entity:Respawn(spawnPos) From my point of view it should work. Any help? Edit: I just found it out. Turns out that this works: entity.script:Respawn(spawnPos) A little explanation would be welcome
-
Hello! This one's driving me crazy. I can't simply understand why I get an attempt to call method 'setPosition' (a nil value) et the entity:setPosition(spawnPos) This two lines print(entity:GetKeyValue("name")) print(self.respawnPoint:GetKeyValue("name")) give me a desired output: Player name Spawn point name Here is the code... Script.respawnPoint = "" --entity "Respawn point" function Script:Collision(entity, position, normal, speed) if (entity:GetKeyValue("name") == "Player") then spawnPos = self.respawnPoint:GetPosition() print(entity:GetKeyValue("name")) print(self.respawnPoint:GetKeyValue("name")) entity:setPosition(spawnPos) end end It seems to me that in the editor everything is setup correctly:
- 6 replies
-
- entity
- setPosition
-
(and 1 more)
Tagged with: