• SetPos doesn't work on prop_vehicle_jeep
    16 replies, posted
When I call SetPos on a jeep it moves but returns to where it was as soon as I interact with it. [code]bind k "lua_run Entity(1):GetEyeTrace().Entity:SetPos(Vector(0,0,0))"[/code] [vid]http://lexi.org.uk/!/gm_flatgrass_2014-4-26_16-28-24.webmhd.webm[/vid] It does seem to actually move rather than just being invisible, since I can use the physgun on things behind it. [vid]http://lexi.org.uk/!/gm_flatgrass_2014-4-26_16-35-19.webmhd.webm[/vid]
I believe you have to move all of its physics objects too.
When did this happen? I found this because I had GM10 code that moved and rotated vehicles that [i]used[/i] to work without problem. I'll try that now, but if it's now required how do I deal with rotation? I don't want to have to calculate rotation matrices for the offsets or anything :/
GM10 was a long time ago, maybe it's a Source 2007 thing? Don't forget that we have two vehicle classes, prop_vehicle_jeep for jalopy, and prop_vehicle_jeep_old for Jeep.
[QUOTE=Robotboy655;44649934]GM10 was a long time ago, maybe it's a Source 2007 thing? Don't forget that we have two vehicle classes, prop_vehicle_jeep for jalopy, and prop_vehicle_jeep_old for Jeep.[/QUOTE] But they both use the prop_vehicle_jeep. Would this be related to the fact that you can't freeze a jeep with the physgun in GMod 13?
[QUOTE=Mors Quaedam;44650035]But they both use the prop_vehicle_jeep. Would this be related to the fact that you can't freeze a jeep with the physgun in GMod 13?[/QUOTE] [URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/autorun/base_vehicles.lua"]No they don't.[/URL] Although I have no idea what their differences are. You can't freeze a jeep because it is hardcoded to be like that. I don't think it has something to do with this.
I believe the jeep freezing change was due to them crashing dedicated servers back in the day (2 years ago or something), garry must've added other code to prevent them from spazzing in other ways.
[QUOTE=Robotboy655;44650066][URL="https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/autorun/base_vehicles.lua"]No they don't.[/URL] Although I have no idea what their differences are. You can't freeze a jeep because it is hardcoded to be like that. I don't think it has something to do with this.[/QUOTE] You could freeze the jeep in GMod 12. If the jeep uses prop_vehicle_jeep_old why does entity:GetClass() return a prop_vehicle_jeep? [t]http://ss.infd.us/linux/2014-04-26@17-47-48.png[/t] [editline]26th April 2014[/editline] In reply to the OP's problem, try using SetPos() on the Jalopy.
SetPos on jalopy doesn't work, and SetPos on all physics object doesn't seem to be working either.
[QUOTE=Mors Quaedam;44650156]You could freeze the jeep in GMod 12. If the jeep uses prop_vehicle_jeep_old why does entity:GetClass() return a prop_vehicle_jeep? [t]http://ss.infd.us/linux/2014-04-26@17-47-48.png[/t][/QUOTE] It reports itself as an old to me [code]] lua_run print(that()) > print(that())... Vehicle [91][prop_vehicle_jeep_old] [/code] [QUOTE=Robotboy655;44650228]SetPos on jalopy doesn't work, and SetPos on all physics object doesn't seem to be working either.[/QUOTE] I know this doesn't: [code] function SetVehiclePos(ent, pos) print("hi", ent:GetPhysicsObjectCount()) local i; for i = 0, ent:GetPhysicsObjectCount() -1 do local phys = ent:GetPhysicsObjectNum(i); local offset = ent:WorldToLocal(phys:GetPos()); print(i, offset); phys:SetPos(pos + offset); end ent:SetPos(pos); end [/code] I'll post an issue. [editline]26th April 2014[/editline] As an interesting note, it seems like it actually does move. You can jump on it: [vid]http://lexi.org.uk/!/gm_flatgrass_2014-4-26_18-26-20.webmhd.webm[/vid] And even get into it: [vid]http://lexi.org.uk/!/gm_flatgrass_2014-4-26_18-29-57.webmhd.webm[/vid]
Are you :Spawn( )ing and :Activate( )ing it ? My vehicle spawn script still works, and it uses SetPos to move them to their spawn marker...
[QUOTE=Acecool;44654481]Are you :Spawn( )ing and :Activate( )ing it ? My vehicle spawn script still works, and it uses SetPos to move them to their spawn marker...[/QUOTE] I'm spawning it via the sandbox menu in those videos, which does indeed do that, as do my scripts. Can you run [lua]Entity(1):GetEyeTrace().Entity:SetPos(Vector(0,0,0))[/lua] on one of your vehicles?
[QUOTE=Lexic;44656741]I'm spawning it via the sandbox menu in those videos, which does indeed do that, as do my scripts. Can you run [lua]Entity(1):GetEyeTrace().Entity:SetPos(Vector(0,0,0))[/lua] on one of your vehicles?[/QUOTE] Actually, that's one of the ways I also spawn it using the admin_baton where it goes to where I look. Now, if you're setting it client-side it'll "move" then jump right back. The reason it does this is due to prediction or so.. You can use SetPos on entities on the client because other things count as an "entity" such as a client-side-model where entity functions can be called on it, but it isn't a true entity... If you have the code in a shared file, and it's executed on the client ( say via concommand that's in a shared environment ) then it won't move it. If you type the same command through server console then it will.
You can always use prop_vehicle_jeep_old - I ended up using this, and it still functions fine. However, maybe it's limited to sandbox, as I'm not having this issue in my DayZ gamemode, it does SetPos where-ever I want it to, then again, jeeps/vehicles have been derpy since GM13.
[QUOTE=Acecool;44657127]Actually, that's one of the ways I also spawn it using the admin_baton where it goes to where I look. Now, if you're setting it client-side it'll "move" then jump right back. The reason it does this is due to prediction or so.. You can use SetPos on entities on the client because other things count as an "entity" such as a client-side-model where entity functions can be called on it, but it isn't a true entity... If you have the code in a shared file, and it's executed on the client ( say via concommand that's in a shared environment ) then it won't move it. If you type the same command through server console then it will.[/QUOTE] I'm not setting it clientside, I'm not an idiot. SetPos obviously works at least once, because the jeep ends up where you're looking when you spawn it in Sandbox. I'm talking about post-spawn. [editline]27th April 2014[/editline] [QUOTE=Phoenixf129;44657154]You can always use prop_vehicle_jeep_old - I ended up using this, and it still functions fine. However, maybe it's limited to sandbox, as I'm not having this issue in my DayZ gamemode, it does SetPos where-ever I want it to, then again, jeeps/vehicles have been derpy since GM13.[/QUOTE] Could you post a snipit of what you use to reposition jeeps please?
Sure, I am overriding and adding features to the jeep in this function though, so it'll end prematurely. [lua] function SpawnCar(Location, Key) local TheCar = ents.Create( "prop_vehicle_jeep_old" ) TheCar:SetModel( "models/buggy.mdl" ) TheCar.MaxHP = 150 TheCar.Key = Key TheCar.HpStage = 0 TheCar.DamageEffect = NULL TheCar.FireEffect = nil TheCar:SetKeyValue( "vehiclescript", "scripts/vehicles/jeep_test.txt" ) TheCar:SetPos( Location ) TheCar:SetHealth(TheCar.MaxHP) TheCar:Spawn() TheCar:Activate() end [/lua] This will probably not help you in any way as I am spawning it AFTER setpos, but i'll hop on sandbox and see if your issue happens for me also.
Indeed it doesn't, as I said I spawning Jeeps is fine. Were you able to replicate?
Sorry, you need to Log In to post a reply to this thread.