I've started implementing a teleport ability that works like portal, keeps your velocity but changes your direction. This is currently only for players. I've tested it, it works.
Based on the function documentation, SetEyeAngle is one of the few that will work on players. I would like to implement a way for it handle angle difference so instead of changing to a set angle, it changes to an angle relative to how the player entered the portal.
For contraptions, i can see this working much more like I want.
This can be added to the same file as the other, just specify an angle and it will use this:
Code:e2function void entity:warpStuff(vector DestVec, angle DestAng) DestAng = Angle(DestAng[1],DestAng[2],DestAng[3]) DestVec = Vector(DestVec[1], DestVec[2], DestVec[3]) if(!validEntity(this)) then return end if (!util.IsInWorld(DestVec)) then while (!util.IsInWorld(DestVec)) do DestVec = DestVec/1.05 end end if (this:IsPlayer()) then if (!self.player == this) then return end this:SetPos(DestVec) this:SetLocalVelocity(DestAng:Forward() * (this:GetVelocity():Length()*2)) this:SetEyeAngles( DestAng ) else if (!isOwner(self, this)) then return end ConstrainedEnts = constraint.GetAllConstrainedEntities(this) for _, v in pairs(ConstrainedEnts) do EntPhy = v:GetPhysicsObject() EntPhy:SetPos(DestVec + (EntPhy:GetPos() - v:GetPos())) EntPhy:Wake() end end end


LinkBack URL
About LinkBacks





Reply With Quote


Bookmarks