teleport

https://www.youtube.com/watch?v=N3cQjiCs9W0&feature=youtu.be

Teleport script

Script.Target = nil --entity
Script.Enabled = true --bool

Script.entered = false
Script.exited = false
Script.hasCollision = false

function Script:UpdatePhysics()
    if self.entered then
        if self.hadCollision == false then
            if self.exited == false then
                self.exited = true
                self.component:CallOutputs("TriggerExit")

                self.Enabled = true

                self.entered = false
            end
        end
    end
    self.hadCollision = false
end

function Script:Collision(entity, position, normal, speed)
    self.hadCollision = true

    if self.entered == false then
        if self.Enabled == true then
            self.component:CallOutputs("TriggerEnter")

            self.Target.script.Enabled = false

            entity:SetPosition(self.Target:GetPosition())
        end

        self.entered = true
        self.exited = false
    end
end
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License