Stargate places Player behind Gate Sometimes.
Closed this issue ยท 18 comments
Sometimes when going through a Stargate it places you behind the gate. I've searched in the code but it seems like this should not happen because the player is placed on the event horizon.
Could this be because you get noclip for one tick? Basically flying for one tick
Ok so i'm pretty sure it IS because you get noclip. You can even catapult yourself using that bug.
Yeah sounds like the player is not syncing properly all of the time. A solution could be if a player is in noclip to pre-freeze the player to prevent movement.
I think the PrepareTeleport(t) Function also does not always place you in the correct position. It's all very weird.
Its known and very old bug, if someone will able to actually investigate it and find whats wrong - it will be really nice. At the moment there is no devs in cap so feel free to look into it, i might do small cap update before/after new year so..
I did make a few changes. It is a timing problem as far as i can see and i've got a hacky Fix on my side. Will test it on my server and report back when it's better
Ok so there's 2 Problems:
One is the Noclip:
I'm not really sure why it's there altogether.
I just replaced the Whole setting MoveType and a timer with
e:SetPos(pos.New);
e:SetEyeAngles(e:GetAimVector():Angle() + Angle(0,ang.Delta.y+180,0));
e:SetVelocity(vel.New);
-- For some Reason velocity needs to be set twice for it to work.
timer.Simple(0, function()
e:SetVelocity(vel.New);
end)
And it's working just fine.
Other one are the last 3 lines of "PrepareTeleport". They seem to offset you by the size of the object infront of the gate. Wich makes you spawn in front of the gate instead of in the horizon.
I just commented them and now it's working fine. You need to keep the return of course.
Oh and i rewrote the Position getting to be a lot more simple:
local new_pos = g[1]:WorldToLocal(p[1]); new_pos.x = 0; new_pos.y = - new_pos.y -- Making the x coordinate = 0 makes the prop getting teleported directly on the EH!
ret.Entity={
Entity=e;
Position={
New = g[2]:LocalToWorld(new_pos),
Old=p[1],
},
Velocity={
--New=g[2]:LocalToWorld(rotation_matrix*g[1]:WorldToLocal(vel + p[2])) - p[3],
New=g[2]:GetVelocity() + rotation_matrix * vel,
Old=vel,
},
Angles={
Old=ang,
New=ang+AngleDelta,
Delta=AngleDelta,
},
Bones=self:GetBones(e,p[1]),
}
I have to come up with a better way of predicting the improper teleport before it happens. Give me some time
Yeah sure. It's working on my server now and you got what i've done :P Now you do your magic
Ok this would seem to make sense in theory....to detect whether a position is in or behind the gate. And override the position for a perfect spawn.
Should be a lot better than the current version. You still got the Rocket Mode when Jumping and Running Through the gate tho. Because of the Noclip for one Tick. I just set the speed again in the Timer where the noclip gets removed. That fixes that
I wonder if this alone could fix the noclip issue
I have no access to a computer to test atm
Well if you freeze the player you dont really need the noclip at all (Spoiler: You don't need it at all :P)
Just take out the entire Noclip Thing and set the velocity on the next tick. Works perfectly
Well it was just for a second so it doesn't run twice.
@TheMerkyShadow isn't your code removes thing when we may teleport inside of ground and stuck in it? Like if gate are placed bit buried and we going from normal gate to those buried gate.. I think there was check for that for prevent that. So please do more tests.
To be honest i think this will make it worse O.o
Closing this until we get proper fix