Josh Posted September 30, 2018 Share Posted September 30, 2018 6 hours ago, Phodex Games said: Yeah I first thought Prefabs are the problem as well, BUT thats why I set up the test scene with a normally placed box with same conditions as my prefab objects (Scene physics and 0 mass). This is a summary of what I have tested and what happend, again this is a normal object placed in the editor. No Prefab. I think if I find a solution for moving this object I can use the same for my prefabs: SetPosition breaks the collision of the object Move breaks the collision of the object if used twice Joint:Kinematic does not work for static physics objects (I also think it makes no sense to use a joint for a static object...) I know Prefabs are a little weird sometimes, but currently its about a normal object, although I use prefabs in my actual situation. I wonder this problem didn't occur for sombody else yet, it think changing an objects position should be used every now and then... The weird is that in my actual setup the physics just break for models, but not for csg brushes, under different circumstances however, which are a little hard to explain right now, the csg brushes physics broke aswell. If you are using polygon collision then the object can't be physically dynamic. You need convex decomposition for that. However, you can call SetPosition or Move once and the collision will work after that. If you are continuously calling it, it resets collision each frame. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
mdgunn Posted September 30, 2018 Share Posted September 30, 2018 10 minutes ago, Josh said: If you are using polygon collision then the object can't be physically dynamic. You need convex decomposition for that. However, you can call SetPosition or Move once and the collision will work after that. If you are continuously calling it, it resets collision each frame. Could you expand on this a little more. I don't fully think I fully understand this. I know convex decomposition from the editor but not sure I understand the relationship with 'polygon collision' and 'physically dynamic'. Also the 'continuously calling' and 'resetting' sounds very bad. If you move a box a few times and reapply the collision type each time does this lead to checking each frame (and why things sometimes seemed to jiggle about - at least in the past). Are you saying the rechecking each frame is not possible to stop if you want an object you can move many times? Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 30, 2018 Author Share Posted September 30, 2018 40 minutes ago, mdgunn said: Try the below That actually works, BUT the weird is if I change the first SetPosition to self.startPos.x + 5 instead of +1 it does not work ?. However the physics are alright if set back to start position... Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted September 30, 2018 Author Share Posted September 30, 2018 24 minutes ago, Josh said: However, you can call SetPosition or Move once and the collision will work after that Yeah this explains why, in my actual setup, the physics breaks when the prefab is loaded the second time and placed in the scene. At one point I release a room and load another one. When a prefab is loaded in the scene the second time and position is changed physics are broke. You are talking about "continuously" calling this, but I am actually not. I just call it once after a prefab is loaded. Quote Link to comment Share on other sites More sharing options...
Josh Posted September 30, 2018 Share Posted September 30, 2018 49 minutes ago, Phodex Games said: Yeah this explains why, in my actual setup, the physics breaks when the prefab is loaded the second time and placed in the scene. At one point I release a room and load another one. When a prefab is loaded in the scene the second time and position is changed physics are broke. You are talking about "continuously" calling this, but I am actually not. I just call it once after a prefab is loaded. This is not how I would expect it to behave. If you upload an example I can try then I can determine what's going on. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Phodex Games Posted September 30, 2018 Author Share Posted September 30, 2018 17 minutes ago, Josh said: If you upload an example I can try then I can determine what's going on. Well to see the problem I am explain I would need to upload my whole project, which is relatively large. If I have time I can try reproducing the error in a smaller setup and upload it here. But as the tests with the box results in the same behavior (disabled physics when setting position after an entity is spawned) I though it is actually the same error as with my more complex scene... Sorry I don't understand why the setup I and mdgunn described is not enough to examine the problem... I mean the question still remains, how to change an objects position with static scene phyiscs after its placed in scene. I see no solution yet. I understand that it has to do with the physics engine not updating the new position of the object, but what to do against it? Quote Link to comment Share on other sites More sharing options...
Josh Posted September 30, 2018 Share Posted September 30, 2018 I do not want to spend the afternoon trying to recreate a certain situation from a description, when there is a good chance I will not be able to, or will end up creating something other than what was described. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Phodex Games Posted September 30, 2018 Author Share Posted September 30, 2018 18 minutes ago, Josh said: or will end up creating something other than what was described. Well ok I guess you are right. I just meant I need like 5 minutes to setup a scene like this. I know you are busy and I appreciate you take the time... I attached a test project. Just open the start.map. If you press "K" the box moves and you can walk through the box. Now the question is how to move it without breaking the physics. TestLevel.zip Quote Link to comment Share on other sites More sharing options...
mdgunn Posted September 30, 2018 Share Posted September 30, 2018 1 hour ago, Phodex Games said: That actually works, BUT the weird is if I change the first SetPosition to self.startPos.x + 5 instead of +1 it does not work ?. However the physics are alright if set back to start position... Strange, I tried self.startPos.x + 5 instead of +1 and it goes back and forth multiple times fine still. move_csg.lua start3.map Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted October 1, 2018 Author Share Posted October 1, 2018 14 hours ago, mdgunn said: Strange, I tried self.startPos.x + 5 instead of +1 and it goes back and forth multiple times fine still. I downloaded your files. First it worked, but when I created a new cube and changed it to +15 it did again not work. I now also experienced, when changing back to +5 with another cube that just the front of the box had physics and I can walk inside the cube from the sides. Play around with different pos values (like +5 +15 +25) and you will see the physics break again... Quote Link to comment Share on other sites More sharing options...
mdgunn Posted October 2, 2018 Share Posted October 2, 2018 On 10/1/2018 at 11:08 AM, Phodex Games said: I downloaded your files. First it worked, but when I created a new cube and changed it to +15 it did again not work. I now also experienced, when changing back to +5 with another cube that just the front of the box had physics and I can walk inside the cube from the sides. Play around with different pos values (like +5 +15 +25) and you will see the physics break again... I've never yet seen the physics break if I have an item with mass. In my scene with +15 it would be drop off floor and gain large velocity so went sent back may miss floor collision and appear to act strange. Maybe this is what you saw but maybe it was something else. When I extend the floor and set to 15 I can't get a problem no matter how many times I move the cube...as long as the cube has some mass. I can see the problem in your test level where I can walk through the cube after moving it. To me this is because you have no mass set. Got a couple of questions:- a) Do you need to move bits of your dungeon after you place them - why would they not be just set in place once? It is dynamic during level? b) Why not have the bits HAVE mass and sit them on an underlying 'scene floor' that does not move? Are you worried these bodies are being computed all the time? I think the engine handles this and treats them as 'at rest'. Debug mode has a counter for active items and it should go to 0. I tried a few things to try to explore the problem such as trying to re-apply a physics shape object and changing mass to 1 then 0 or setting gravity to 0 or not affecting the item but unless I allowed gravity to actually affect the item (e.g. mass over 0 and some gravity) the item would not regain collisions with it's physic shape (beyond the 1 allowed move). Seems like the engine should allow this but unless Josh knows a way if this is now any clearer as to what you want then you may be a bit stuck. Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted October 3, 2018 Author Share Posted October 3, 2018 8 hours ago, mdgunn said: I've never yet seen the physics break if I have an item with mass Ah yeah the new cube I created in your scene had 0 mass actually. It does actually work with mass > 0. The problem is if I set mass to my scene object then it sometimes just falls through the ground (which by the way is why I did not set a mass), or it behaves like a dynamic physics object, which I not want, I maybe have some wodden planks at the ceiling and don't want them to fall on the ground ^^. 8 hours ago, mdgunn said: Do you need to move bits of your dungeon after you place them Well I have different room layouts & different prebuild furnishing sets. A few rooms are preloaded and then everytime you exit a room an new one gets loaded and placed at the right position. This works in the first place, but I experienced that after a certain number of rooms, the collison of some objects are broken (so far just the furnishing objects, not the room itself were affected). 8 hours ago, mdgunn said: Why not have the bits HAVE mass and sit them on an underlying 'scene floor' that does not move? Could you explain this a little more? As explained about arent my objects flying around with mass enabled? How would you created the scene floor and not make him move? By the way, thanks for you help its actually one of the last things I need to get done before I can release it... Quote Link to comment Share on other sites More sharing options...
mdgunn Posted October 5, 2018 Share Posted October 5, 2018 On 10/3/2018 at 8:44 AM, Phodex Games said: Could you explain this a little more? As explained about arent my objects flying around with mass enabled? How would you created the scene floor and not make him move? Sorry been away a couple of days. I didn't fully understand the second sentence above. My idea of 'scene floor' may not be a solution as I think you are having issues I haven't seen yet but the idea was that if physics can be harmed by moving things around then have a static object/cube or a number of them on which the other moving level parts would sit. This way if the underlying level floor is never moved then physics would not break for it and other parts on top can be moved as they will regain their physics collision after the move if they have mass. Just an idea. In the image below the orange block would be the static floor and the blue bits would be the actual bits you want of your level which, hopefully, could be moved. You may never even have the user able to see/reach the underlying orange supporting floor. It sounds like you have other issues I have not seen yet. I think the supplied project seemed to work in the way Josh intended so maybe you need to supply one or more further examples. Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted October 5, 2018 Author Share Posted October 5, 2018 Ok so I found a workaround for the issue. It actually works pretty good so far, still its not ideal, and I just tested it for a single non-prefab object with no parent, but it is at least something. A Physics:Refresh() function maybe would be a good idea? But thats just my unprofessional opinion. function Script:Start() self.startPos = self.entity:GetPosition(true) end function Script:UpdateWorld() if self.moved then --Move the object one frame after I gave it mass then remove the mass and set it back to scene collision self.entity:SetPosition(self.startPos.x + 15, self.startPos.y, self.startPos.z, true) self:SetMoveMode(false) end if keyHit.K then self:SetMoveMode(true) self.moved = true end end function Script:SetMoveMode(state) if state then self.entity:SetCollisionType(Collision.Prop) self.entity:SetMass(10) else self.entity:SetCollisionType(Collision.Scene) self.entity:SetMass(0) end end Future will show if this will also work for my more complexe scene... EDIT: @mdgunn Just saw your reply. Yeah my sentence was a little weird. I meant that with this method, all of my objects will have dynamic physics, and objects (like wodden planks) I place on the roof of a room will fall to the ground when mass is enabled. However as you can see above I found a solution, at least for the moment. Quote Link to comment Share on other sites More sharing options...
mdgunn Posted October 5, 2018 Share Posted October 5, 2018 I get it about the planks now. I suppose light fittings on wall or ceiling might be a similar thing. Sometimes you really just want something to be STATIC. Yeah this was about where I got to with my quick tests. There might be a slight improvement where you also set gravity to 0 (or near zero if zero is a problem) to further minimise movement between frames when mass applied if there is some movement. Seems like your use case is not that strange and there should be a way for the engine to not require the developer to do this additional setup. Maybe Josh can chip in and tell us a different way that wasn't apparent before, or add support for this to work without the workaround. 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.