Parent Entity to Entity without losing it's physics
13 replies, posted
I'm trying to make a few models combined into 1 entity, so far I used SetParent to combine them into 1, but you cannot physgun those other objects only the parent and they seem not to have physics or collide with anything they just go through the world.
-Show the code
-Do they have physics before you parent them?
[QUOTE=Netheous;45444334]-Show the code
-Do they have physics before you parent them?[/QUOTE]
I parent them before spawn
[lua]
function ENT:SpawnExtraModels()
local ExtraModels = ents.Create("prop_physics")
ExtraModels:SetPos()(self:GetPos())
ExtraModels:SetParent(self)
ExtraModels:Spawn();
end
[/lua]
There might be a better way to do it, as I said what I want is a few models creating a 1 big entity.
You can't parent entity to another entity without losing physics.
[QUOTE=Robotboy655;45444376]You can't parent entity to another entity without losing physics.[/QUOTE]
Is there a way to make a few entities into a one giant entity(with hitbox being as the size of all the entities)?
Weld them together first and the collisions for the child are preserved.
If only it were possible to get the raw information of the mesh, combine it with another, and then generate an IMesh and use its collisions.
[QUOTE=Walrus Viking;45475543]If only it were possible to get the raw information of the mesh, combine it with another, and then generate an IMesh and use its collisions.[/QUOTE]
You can already do that.
[url=http://wiki.garrysmod.com/page/PhysObj/GetMeshConvexes]PhysObj:GetMeshConvexes[/url]
[url=http://wiki.garrysmod.com/page/Entity/PhysicsInitMultiConvex]Entity:PhysicsInitMultiConvex[/url]
It needs a bit of work to make sure players collide with your custom physics object correctly, but it's definitely possible.
[QUOTE=_Kilburn;45475741]You can already do that.
[url=http://wiki.garrysmod.com/page/PhysObj/GetMeshConvexes]PhysObj:GetMeshConvexes[/url]
[url=http://wiki.garrysmod.com/page/Entity/PhysicsInitMultiConvex]Entity:PhysicsInitMultiConvex[/url]
It needs a bit of work to make sure players collide with your custom physics object correctly, but it's definitely possible.[/QUOTE]
Could you please elaborate on "It needs a bit of work to make sure players collide with your custom physics object correctly"?
[QUOTE=Newbrict;45475849]Could you please elaborate on "It needs a bit of work to make sure players collide with your custom physics object correctly"?[/QUOTE]
Use [url=http://wiki.garrysmod.com/page/Entity/EnableCustomCollisions]Entity:EnableCustomCollisions[/url], initialize the physics object on both the server and the client, freeze the clientside physics object and then manually reposition it every frame so that it always follows the entity. It's somewhat hacky, but it should result in an entity you can stand on just fine.
[QUOTE=_Kilburn;45475741]You can already do that.[/QUOTE]
I was being sarcastic because people are like 'How do I do it', when they've got all the resources in their face. I was simply just dropping an idea to plant in their heads.
I would like to know more about this. Do you have a code sample that shows how to give a prop a custom collisions?
According to [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html[/url] (yes, I know gmod wiki is usually better, but I usually need the additional info and/or different examples, etc.)
[QUOTE]Child entities will move with the parent entity.
Currently, entities with a parent can not be safely interacted with. Bounding boxes are invisible and are not aligned properly.
Currently, through my testings, entities that are parented and that are moved with the phys gun, create a clone of it's physics model somewhere else on the map. This physics model can collide with players and entities.
Currently, you can parent 2 entities and weld them to restore the physics on the child and still have some qualities of parenting.
You can also use Entity:SetSolid() instead of welding to restore the physics.[/QUOTE]
So, according to this, using self:SetSolid( SOLID_VPHYSICS ) or constraint.Weld(<insertcodehere>) would reset physics to the objects, correct?
[QUOTE=Ekuland;45482275]According to [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4bfa.html[/url] (yes, I know gmod wiki is usually better, but I usually need the additional info and/or different examples, etc.)
So, according to this, using self:SetSolid( SOLID_VPHYSICS ) or constraint.Weld(<insertcodehere>) would reset physics to the objects, correct?[/QUOTE]
SetParent is super bugged from my testing it seems to literaly(yes the wiki says that too) create another "invisible prop" in the map that people collide with.
Sorry, you need to Log In to post a reply to this thread.