Search the Community
Showing results for tags 'Entity'.
-
I want to use multiple scripts in my character, but I don't want to change the FPS script. I hope this feature will be added in the future. Leadwerks / Unity Thanks Josh..
-
Hello there, I have 2 questions and any help / idea is welcome. 1. How can I make sure that the camera does not go off terrain? 2. I need to move the camera forward (0Z) and sidewards (0X) along it's own axes, but without taking in consideration the rotation around 0Y axis (up/down). Any idea? I tried to make some pictures, hope they help: and an example: PS: I have solutions for both problems, but I am not satisfied with them. 1. "trap" the camera inside a cube 2. increment the camera position with sin(y rotation) on 0X, and with cos(y rotation) on 0Z code below: PPS: It didn't take the whitespaces when I copy-pasted from VS. Any idea how to solve this? PSPS: I posted the camera movement method on pastebin: http://pastebin.com/BLBQgjAj
-
Hi, I'm not sure do I miss something obvious but for me self.entity:Hide() does not work as intended. Below I got a very simple enemy LUA script, which should on collision be 'removed' from gameplay. Object on collision does get hidden and not being rendered but it's still there and all the physics apply. According to http://www.leadwerks.com/werkspace/page/api-reference/_/entity/entityhide-r181 this should not be the case. function Script:Start() self.entity:SetMass(1) self.entity:SetGravityMode(false) self.entity:SetFriction(0,0) self.entity:SetCollisionType(Collision.Prop) self.health=50 self.points= 100 self.endof = 0 end function Script:Collision(entity) self:Hurt(100) end function Script:Hurt(damage) if self.health > 0 then self.health = self.health - damage if self.health<= 0 then self.entity:Hide() self.entity:SetMass(0) self.entity:SetCollisionType(0) PlayerScore=PlayerScore+self.points end end end function Script:UpdatePhysics() --Get the game window local window = Window:GetCurrent() local evel = Vec3(0,0,-5) self.entity:SetVelocity(evel) end Can somebody explain ? Just to be clear Hurt is triggered on it's own when bullet hits the enemy with this script attached to it where collision is with player's model (currently a box). Regardless of collision with the player or hit by the bullet, self.entity:Hide() just stops rendering the object on the screen but it's still there and after respawn (respawn not reload) I can hit it again when enemy is hidden.
-
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:
-
I just noticed a really annoying glitch where if I put a entity with a script, the script gets deleted after I click something else, it's happening everywhere, and it dind't happen before. I started using the beta build to see if it would be fixed there to no avail.
-
It seems if you save a script from the editor (not the one currently active in the entity's scripts tab) parameter fields get messed up with fields from another script. No file corruption or anything like that is apparent, hopefully just a visual bug. But still. Please see the video. http://www.olbyonline.com/bin/leadwerks/ScriptEditorParamsMess.mp4
- 3 replies
-
- script editor
- lua
-
(and 2 more)
Tagged with:
-
First of all: this might be pretty basic knowlege, but i didnt find any answers to this in the documentations. (its possible that i just didnt find it) How can i access a entitys properties form within another entitys script? Let me give you a example: I want to Point a entity at another entity. I would think that this would work: (this line is in the script of the entity i want to point at another entity) self.entity:Point(exampleEntity.entity) If i try to execute it, i get the error message: self.entity:Point(PlayerPos.entity) Let me give you another example, i want to move a entity to the position of another entity: self.entity:SetPosition(exampleEntity.entity:GetPosition(true)) If i try to execute it, i basically get the same error message. I dont know what to do about that. I know that there are other ways of pointing an entity at another entity and moving a entity to the position of another entity, but it would be easier and spare me much work to simply do it like this. I appreciate any help
-
Sorry for the many questions lately, but I've been getting into various issues! Anyway, is there a way in Lua to swap a parent mesh? So for instance, in my case I have a car, and I want to be able to change the car body mesh without deleting the entity. Is this possible?
-
I'm familiarizing myself with Leadwerks and so I have a simple test map that lets me place block prefabs like Minecraft. How can I retrieve the name from a pickinfo.entity? I tried the following, but it throws an error in Print in the window:MouseDown(1) check: (argument #3 is 'string'; '[no object]' expected.) function Script:UpdateWorld() if block == nil then block = Prefab:Load("Prefabs/CM/Block.pfb") block:SetKeyValue("name","Block") block:SetCollisionType(Collision.Prop) end local pickinfo = PickInfo() local mousePos = window:GetMousePosition() if (self.player.script.camera:Pick(mousePos.x, mousePos.y, pickinfo, pickradius, true)) then block:SetPosition(Vec3(math.floor(pickinfo.position.x), math.floor(pickinfo.position.y), math.floor(pickinfo.position.z)) + Vec3(pickinfo.normal.x, pickinfo.normal.y/2, pickinfo.normal.z)) end if window:MouseDown(2) then -- Place the block block = nil end if window:MouseDown(1) then -- Delete the block if pickinfo ~= nil then if pickinfo.entity ~= nil then System:Print(pickinfo.entity:GetKeyValue("name")) end --if pickinfo.entity:GetKeyValue("Name") == "Block" then -- pickinfo.entity:Release() --end end end end The other issue I'm having is that the placed prefabs have no physics collision. Thanks, Mike
-
Hi! I recently encountered a problem when I tryied to get an entity based on its name. First I made a box in LE as "Box 1" in the scene list/graph. And I was trying to find the entity "Box 1" in C++ but for some reason it does not show up. I am not sure how to interact with this box otherwise. list<Entity*>::iterator iter; for (iter = world->entities.begin(); iter != world->entities.end();++iter) { fileLogger.Log("Entity: " + (*iter)->GetKeyValue("name")); } When looking through the log I don't find "Box 1" anywhere. ... [21:13:39] Entity: [21:13:39] Entity: [21:13:39] Entity: [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: cardboardbox [21:13:39] Entity: Directional Light 2 [21:13:40] Entity: [21:13:40] Entity: BarbarianLDigit110 [21:13:40] Entity: BarbarianLFoot [21:13:40] Entity: barbarian_knee_pad_L [21:13:40] Entity: BarbarianLCalf ... In LE scene graph there is "Directional Light 2", several "cardboardbox" and last "Box 1". Rest is loaded from C++. I don't know what to do, please help!