Wierd car teleport.. Anyone know why this is happening?
2 replies, posted
Hello there, thanks for taking the time to read this :)
Im doing a game that involves vehicles being set up and moved to certain places on the map, but when I use SetPos() on my vehicles (TDMcars vehicles, basically a prop_vehicle_jeep) , then get in them they teleport back to their original location :S
this is an example of what I'm trying, if anyone could point out what I'm missing that would be great! (I'm using VCmod too, but as that's just vehicle scripts I don't think that's the issue..)
function Movepolicecars()
for k, v in pairs( ents.GetAll() ) do
if IsValid(v) and v:GetClass() == "prop_vehicle_jeep" then
if v:GetName() == "policecar1" then
v:SetPos(Vector(-4146.3125, 2470, -2166.2188))
v:SetNetworkOrigin(Vector(-4146.3125, 2470, -2166.2188))
elseif v:GetName() == "policecar2" then
v:SetPos(Vector(-4448.4063, 2470, -2166.2188))
v:SetNetworkOrigin(Vector(-4448.4063, 2470, -2166.2188))
elseif v:GetName() == "policecar3" then
v:SetPos(Vector(-4751.375, 2470, -2166.2188))
v:SetNetworkOrigin(Vector(-4751.375, 2470, -2166.2188))
elseif v:GetName() == "policecar4" then
v:SetPos(Vector(-3853.1563, 2470, -2166.2188))
v:SetNetworkOrigin(Vector(-3853.1563, 2470, -2166.2188))
end
end
end
end
Thanks for your time!
-2Sneaky
[editline]24th March 2015[/editline]
Forgot to clarify, I can get in the car in its new location - then it teleports back to where it used to be with me in it.
You can't set the position of a vehicle and just be done with it. You will have to call v:Spawn() on it after you change the position.
If you search, this has been covered a few times before. You'll find a bit more information as to the caveats as well.
Thanks mate, appreciate it :)
Sorry, you need to Log In to post a reply to this thread.