Search the Community
Showing results for tags 'respawn'.
-
Hello, i need some help with the next issue: I have a flying machine, helycopter, and i want to launch a missile(obuz in my script), with physics to hit terrain. All working fine, but i cant figure this things: I want to respawn the missile(obuz) back on helycopter I want to make a big explosion hitting terrain. Emiter should be child of missile ???How to do that in collosion function and where?? I created a pivot child to helycopter, also the missile, created in Leadwerks, as child of pivot, not sure what kind of physics collision to set, prop, trigger,... I made a script combined from few others, such us respawnpoint, deadtrigger, collision function, but ....no more ideas....anybody can help??? here is the script, attached to my missile: Script.respawnPoint = "" -- entity "Respawn Point" Script.soundfile1=""--path "Sound 1" "Wac file (*.wav):wav|Sound" Script.soundfile2=""--path "Sound 2" "Wac file (*.wav):wav|Sound" Script.soundfile3=""--path "Sound 3" "Wac file (*.wav):wav|Sound" Script.soundfile4=""--path "Sound 4" "Wac file (*.wav):wav|Sound" Script.threshhold=2--float "Threshhold" Script.maxfrequency=300--minimum delay between sound plays Script.range=200--float "Range" Script.window = Window:GetCurrent() ImpactNoiseLastSoundTime=0-- This will be shared among all instances of this script and ensure we don't play too many sounds function Script:Start() self.sound={} for n=1,4 do local filepath = self["soundfile"..tostring(n)] if filepath~="" then local noise = Sound:Load(filepath) if noise~=nil then table.insert(self.sound,noise) --self.sound[#self.sound+1]=noise end end end end function Script:Collision(entity, position, normal, speed) if speed>self.threshhold then if #self.sound>0 then local collisiontype = entity:GetCollisionType() if collisiontype==Collision.Prop or collisiontype==Collision.Scene then local t = Time:GetCurrent() if t-ImpactNoiseLastSoundTime>self.maxfrequency then ImpactNoiseLastSoundTime=t local n=math.random(#self.sound) local noise = self.sound[n] self.entity:EmitSound(noise,self.range) --if (entity:GetKeyValue("name") == "obuz") then -- spawnPos = self.respawnPoint:GetPosition() -- entity:SetPosition (spawnPos) --end end end end end end function Script:UpdatePhysics() self.move = Vec3(0,0,0) if (self.window:KeyDown(Key.B)) then self.entity:SetMass(1) self.entity:SetParent(nil) self.entity:AddForce(0,0,200, false) end end
-
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