Jump to content

Opposite of spawning


Evil Resident
 Share

Recommended Posts

I added this bit of code to MonsterAI.lua

 

make the end of the setmode function look like this

 

elseif mode=="dying" then

self.entity:Stop()

self.animationmanager:SetAnimationSequence("Death",0.04,300,1,self,self.EndDeath)

elseif mode=="dead" then

self.entity:SetCollisionType(0)

self.entity:SetMass(0)

self.entity:SetShape(nil)

self.entity:SetPhysicsMode(Entity.RigidBodyPhysics)

if self.target ~=nil then

self.target = nil

end

self.deadtime=Time:GetCurrent()

end

 

the end of the UpdatePhysics to look like this

 

 

elseif self.mode=="attack" then

if self.attackbegan~=nil then

if t-self.attackbegan>self.attackdelay then

if self.target.entity:GetDistance(self.entity)<1.5 then

self.attackbegan=nil

self.target:Hurt(self.damage)

end

end

end

local pos = self.entity:GetPosition()

local targetpos = self.target.entity:GetPosition()

local dx=targetpos.x-pos.x

local dz=targetpos.z-pos.z

self.entity:AlignToVector(-dx,0,-dz)

elseif self.mode=="dead" then

if t>self.deadtime+1000 then

self.entity:SetPosition(self.entity:GetPosition().x,self.entity:GetPosition().y-0.01,self.entity:GetPosition().z)

end

 

if t>self.deadtime+2000 then

 

self.enabled=false

self.entity:Release()

end

end

 

 

You should also add

 

Script.deadtime=0

 

to the list of Private values at the top of the .lua file

 

When your monster is killed, it lies dead for 1 second, then sinks into the ground for the next second and the release causes it to disappear.

Link to comment
Share on other sites

Thanks for the replys.

 

I was thinking of "releasing" inanimated objects. When thrown in a meat grinder they hit a hidden box with the collisiontrigger script and they disappear from the game and that trigger a particle emitter for a second or so. Unfortunaly, i'm not a very good scripter...Could some of you just give me some hints to get me started. I don't want a script from some one, just the general idea so i can make this happen an learn at the same time.

 

Thanks for your time.

post-12907-0-50509100-1420040414_thumb.jpg

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...