Is it possible to clone and move parts of a level & have separate physics scenes?

Good day,

I will be able to subscribe no sooner than next month, so I wanted to ask whether two features that I consider critical for my planned game are possible (without some really ugly workarounds), since I have no means to check that for myself currently, and my search through the public documentation didn’t give me conclusive answers. I hope that it is alright to ask two questions at once - in this use scenario, they are closely related though.

I think it might be best if I first try to explain the problem I will be trying to solve. I want to be able to create entire “rooms” (containing lights, level geometry, anything) which can then be cloned at any time during the gameplay and then be moved/rotated by code/blueprints more or less every frame (you can think of them perhaps as spaceships, moving around in space while the interior is unaffected). Physics inside these rooms should act as if the room didn’t move/rotate at all, the perceived rotation/translation being really only a rendering transformation. Light from at least major external light sources (the sun) should affect the interior of the rooms in case there are windows/holes and combine with the room’s baked and dynamic lighting.

From my (limited) prior experience with other game engines, I suspect at least two possibly major problems with this:

  • First, can the “rooms” (parts of level) be cloned and moved/rotated and can I expect the lighting to behave in a sane manner in such case (combining static and dynamic light correctly)?
  • And second, is it possible to have separate physics scenes to achieve the behavior that I (hopefully at least somewhat clearly) explained above, ie. have a stationary axis-aligned physics frame of reference per each “room” and its contents?

Many thanks in advance for any answer and I apologize for perhaps a bit incoherent explaination of the problems.

I just went through this exact problem so I’ll share what I came up with. Basically I needed a pawn that becomes “based” in a ship that has an arbitrary and potentially changing location and rotation. Gravity needs to always be based on the ship’s orientation and the ships movement should not affect the physics of the pawn. Effectively it is Star Trek physics.

Cloning solution: I had the same idea of cloning ships, pawns, and all other world objects and basically moving the cloned world around each player while the ship stays stationary - giving the illusion of movement. I got this basically working but it involved a lot of complex transforms and it had a noticeable effect on performance. It could be done much faster by transforming the clones at a lower level in native code (believe it or not I only used Blueprint). However there are so many things to keep track of (juggling multiple virtual coordinate systems, lighting, etc.) that I realized this is not the best solution.

Physics scenes: It is possible with PhysX to have multiple physics scenes although UE4 isn’t setup to make this easy to do. If you put the time in to code the support it is probably the most elegant solution. However I decided to try a different route which involved less low-level coding.

Parenting and Relative Transforms: The solution I ended up with (which is working now) was simply to attach the pawn to the ship and use relative location and rotation updates to replicate the usual pawn physics. Unless you do the cloning solution you have to write your own pawn physics in order to support angled physics anyway. You have to track all of your own acceleration, velocity, and location updates as well as apply gravity but it’s pretty easy to do in relative coordinates and the attachment code handles inheriting all the ship movement seamlessly.

I should add that there are two ways to attach a pawn to an object… regular attachment and physics constraints. I can save you some time by not recommending your pawn be a physics object with a constraint. Constraints are springy attachments and even if you jack up the strength on the constraint it is going to jiggle around or drift if your ship is moving a lot. Regular attachments don’t have this problem. I had hoped to use physics because it would be nice to just “apply force” to simulate gravity but real physics just can’t eliminate the effects of the base platform moving no matter what you try.