nick.ace Posted December 6, 2014 Share Posted December 6, 2014 I'm running into a problem where I want to manually select a location for a car to teleport to. Anyway, SetPosition() on self.entity causes weird physics glitches if the new position is too far away. Is there a way to manually change positions? I need cars to disappear and respawn in a city full of cars (and it's obviously impractical to put hundreds of cars in at once), so I was just going to move them, but I'm open to hearing other suggestions! Quote Link to comment Share on other sites More sharing options...
gamecreator Posted December 6, 2014 Share Posted December 6, 2014 Have you tried the Physics move command? http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entityphysicssetposition-r190 Quote Link to comment Share on other sites More sharing options...
nick.ace Posted December 6, 2014 Author Share Posted December 6, 2014 Just tried it, but cars went crazy like before (like spinning and flying around). Maybe if I play with the setting a little I can get it to work. I think part of the problem is that the vehicle part of the car actually isn't an entity. Vehicles have their own class, and although they are attached to an entity, they don't behave like most physics. Quote Link to comment Share on other sites More sharing options...
diedir Posted December 6, 2014 Share Posted December 6, 2014 Hi have you tried Entity::GetMatrix() Enttity::SetMatrix() i use that in Le2 with physics cars Quote AMD Ryzen 5900HX - Nvidia RTX 3070 - 32 Go - 1To SSD - W11 Link to comment Share on other sites More sharing options...
nick.ace Posted December 7, 2014 Author Share Posted December 7, 2014 I just tried that too, but the car body appears to get separated from the wheels and the wheels have the physics glitches as well. Also, I tried releasing the car from memory, but this causes the game to crash. Apparently, vehicles cannot be released as of now, at least this seems to cause a crash. Quote Link to comment Share on other sites More sharing options...
Naughty Alien Posted December 7, 2014 Share Posted December 7, 2014 I believe you should disable car related physics bodies from collision before repositioning takes place, and activate it again after everything is set to new location. 1 Quote Link to comment Share on other sites More sharing options...
BES Posted December 7, 2014 Share Posted December 7, 2014 I believe you should disable car related physics bodies from collision before repositioning takes place, and activate it again after everything is set to new location. That makes sense ...didn't think of that. Quote Threadripper 2920X Gen2 CPU(AMD 12-core 24 thread) | 32Gigs DDR4 RAM | MSI Nvidia GeForce RTX 2070 Stock OCed | ASRock X399 Professional Gaming Motherboard | Triple M.2 500Gig SSD's in Raid0 Windows 10 Pro | Blender | Paint.Net | World Machine | Shader Map 4 | Substance Designer | Substance Painter | Inkscape | Universal Sound FX | ProBuilder | 3D World Studio | Spacescape | OpenSky | CubeMapGen | Ecrett Music | Godot Engine | Krita | Kumoworks | GDScript | Lua | Python | C# | Leadworks Engine | Unity Engine Link to comment Share on other sites More sharing options...
gamecreator Posted December 7, 2014 Share Posted December 7, 2014 Is that done by setting mass to 0? I saw on this page that If you don't want an entity to use any physics at all, set the mass to 0 with Entity::SetMass(). but SetMass says Entities with zero mass will still collide with other objects, but will be unmovable and unresponsive to physical forces. So I'm a little confused. I assume by "unmovable" it means by Physics commands, in which case the documentation should be a little more clear/specific. 1 Quote Link to comment Share on other sites More sharing options...
nick.ace Posted December 8, 2014 Author Share Posted December 8, 2014 I totally forgot how to disable physics! Thanks guys! It works pretty well, just have to find a way to prevent the car from flipping over when spawning. Edit: After more tests, there seems to be an issue, but it can sort of be fixed with a little moving of code. This is the order of commands to effectively move a vehicle: self.entity:PhysicsSetPosition() self.entity:SetMass(0) self.entity:SetPosition() self.entity:SetMass(1000) I think that the wheels have to follow a physics object, but then get catapulted away due to the entity having mass. So if you follow this sequence of steps, you should be able to move correctly. I'm just having a problem with the y-offset right now since cars are spawning slightly below the terrain, but that should be easy to fix. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.