Search the Community
Showing results for tags 'hide'.
-
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.