I'm trying to make so shooting at a car freezes it for 3 seconds:
[CODE] local tr = self.Owner:GetEyeTrace()
local trent
local trentpos
if tr.Entity:IsVehicle() then
trent = tr.Entity
trentpos = tr.Entity:GetPos()
trent:SetMoveType(MOVETYPE_NONE)
timer.Create("asd", 3, 1, function() unfreezecar(trent, trentpos) end)
end[/CODE]
[CODE]function unfreezecar(trent, trentpos)
trent:SetMoveType(MOVETYPE_VPHYSICS)
trent:SetPos(trentpos)
end[/CODE]
What happens currently is that I shoot it once, and then it cant move for 3 seconds, but if the person inside is holding down W, after 3 seconds, the car is teleported to where it would've been if it wasn't frozen. I try to fix it with the position there but it doesn't work.
Bump, I think it's necessary to use phys, but I'm not sure how.
Have you tried trent:GetPhysicsObject():EnableMotion(false) to freeze the car and trent:GetPhysicsObject():EnableMotion(true) to unfreeze it? That's the "proper" way to freeze a physics object, you shouldn't change the move type.
Yes, and you must call those functions [b]for every physics object that vehicle has.[/b]
[QUOTE=_Kilburn;42052201]Have you tried trent:GetPhysicsObject():EnableMotion(false) to freeze the car and trent:GetPhysicsObject():EnableMotion(true) to unfreeze it? That's the "proper" way to freeze a physics object, you shouldn't change the move type.[/QUOTE]
Thank you, I have tried it in a new thread, see my latest response here please:
[url]http://facepunch.com/showthread.php?t=1304080[/url]
[QUOTE=Robotboy655;42052208]Yes, and you must call those functions [b]for every physics object that vehicle has.[/b][/QUOTE]
Could you tell me how to do that?
Sorry, you need to Log In to post a reply to this thread.