Braqoon Posted February 3, 2016 Share Posted February 3, 2016 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. Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted February 3, 2016 Share Posted February 3, 2016 Try "release" instead. self.entity:release() 1 Quote Link to comment Share on other sites More sharing options...
Slastraf Posted February 3, 2016 Share Posted February 3, 2016 Open up the EnemyAi.lua script that is included in the advanced fps player project type. Theres also a function like that but without the Hide(). Quote Link to comment Share on other sites More sharing options...
Braqoon Posted February 3, 2016 Author Share Posted February 3, 2016 self.entity:Release() does the trick but docs should be updated on self.entity:Hide() if it does not do what it says. Thanks. Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 3, 2016 Share Posted February 3, 2016 I am not having any collision with a hidden object, but i wonder if something is being messed up in your script based on the number of collisions being reported on first contact much like in your previous post. Suggest putting in a logic check to only allow the first reported collision to call the 'Hurt' function: function Script:Start() ... self.toggle = 1 end function Script:Collision(entity) if self.toggle==1 then self.toggle = 0 self:Hurt(100) end end 1 Quote 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 More sharing options...
Braqoon Posted February 4, 2016 Author Share Posted February 4, 2016 Yes, thought about it but this made no difference. Hide for me only hides object from rendering. Other test is that I can trigger a collision with bullet so my player does not touch it. Enemy is hidden but then it stays on the scene and player can hit it. Anyway Release works as it should so not a big problem for now. 2 Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 4, 2016 Share Posted February 4, 2016 If you found a work around then good. If you ever see this issue again, I would suggest posting an actual example showing hidden objects still colliding because I cannot make it happen and would be curious to see an example of the problem. Quote 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 More sharing options...
Braqoon Posted February 4, 2016 Author Share Posted February 4, 2016 I will do a video, very easy to replicate. Quote Link to comment Share on other sites More sharing options...
macklebee Posted February 4, 2016 Share Posted February 4, 2016 Videos and pics are nice but for something like this I would like to see a working example if possible so that i could test myself. Like I alluded to above, I was not getting collision with a hidden object - using the object script you posted attached to a csg box. So I would be curious to see something I could test that causes this problem. Quote 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 More sharing options...
Braqoon Posted February 4, 2016 Author Share Posted February 4, 2016 sure, Can provide project. Will create from scratch with same scripts so will do test myself as well. Bare with me. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.