Download

Star Trek Physics

Hi,

I was thinking about the following problem… Can perhaps someone point me in the right direction ?

I want to navigate in space with a spaceship and 6 degrees of freedom .
The spaceship is a complete level with nav-meshes and a lot of physic-actors.
It is very possible that characters can move while the spaceship has a full arbitrary transformation.

I know that implemeting a movement-controller with custom gravity vectors would be possible with lot of efforts - however that is not necessary since the free translation/rotation of the ship would be “only” a rendering issue.

I guess a way of achieving this would be to implement the spaceship as a root-actor in a object-hierachy, and only modify the child-render-transforms.

Do you know which methods I would have to modifiy or overload ? I would have to take into account that the physics-scene for the spaceship has another frame of reference than the rest of the universe.
I am not sure yet, but I believe that there would be only one physics-scene - namely the space ship…

Any clues what would be the best way to achieve this ?

Thank you for any help,

Chase

So I think what you’d probably want to do is leave the ship stationary, and rotate the world around it by whatever appropriate amount you need is.

That way you don’t mess up your nav meshes, or anything else, and the player sees everything move appropriately while on the ship. Doesn’t work great if you need to actually get off the ship, but if the game takes place entirely on the ship then you should be able to use that technique.

So when the player steers, you get the rotations and then rotate/translate everything BUT the ship (and stuff on it) by an inverse amount.

Not sure how you’d want to set that all up, and it might be weird with the skybox and such, but that’s one option.

Thanks for the suggestion.

That would be certainly nearly trivial to accomplish, but would also imply to wrap every possible engine object and move it myself as the ship moves. And I am not sure if this is possible for example for gpu-particles.
So, If I have a lot of outside-actors, I also would have to calculate more transforms.

I wonder if there is another way to modify just the render-transforms for a ship hierachy, so the physic-state and navigation won’t be touched.

The problem is, that this would be a two-way-solution since I also would have to update my local transform of the ship and actors as soon as the local physic-state changes.

Has anyone done that yet ?

I am searching for example the code where the current physic-state is written back into the actor-transforms.

I am literally working on this today, I’ll check in here and keep you apprised if I come across or come up with a working solution. I’m working on almost the exact same feel (a game based on a starship, played in first person - where you do not directly fly the ship such as Wing Commander or Privateer, but instead command the helmsman where to go, but allows rotation/turns in any 3d direction) and my first thought was as suggested moving the view of the outside (space is only seen through the windows or viewing screens anyway), however this got weird as I do expect people to be able to leave the ships, and I’m aiming for multiplayer and the logic got weird fast, so I need a way to handle it more ‘correctly’.

Best of luck to you.

edited to add: If you’re interested, I’d be happy to discuss what I’m planning/working on with you, to see if we have any other common ideas or things that one another might find useful, although my schedule currently isn’t very conducive to working together, it would be to talking - at least for the time being.

also edited to add: this does not contain source code, but is an interesting discussion I’ll be focusing on today as well, it seems to share some of the same principle problems as you and I do https://forums.unrealengine.com/showthread.php?6592-Unreal-Z-axis-independent-gravity - I may end up digging into my fork of the engine and seeing if I can affect a change to the limitations currently imposed with gravity, if I do end up going this route I would be happy to make the diffs public.

That’s true, if you have a lot of stuff in the world it’s going to be annoying. Though you might be able to do something like have everything outside the ship be parented to the same object, and simply rotate/translate that object with the inverse of your ship movement.

No idea if that really works, though. You might also consider using Scene2Ds or something for the windows instead, and doing all your movements on the sub-scene.

Alternatively, you could drive the ship the normal way, moving it, and just patch up the navmesh to be considered relative to the ship (if there isn’t already some functionality for that) so that it need not be updated every time the ship moves.

You should be able to make it so that stuff on the ship itself inherits the ship’s motion. Gravity is a different issue - you’d want to look into setting up custom gravity (there’s a thread, but no source, tho the OP of it offered to help others) such that everything in your ship gets a downward gravity relative to the ship, so that regardless if the ship is upside down to the world coordinate frame, gravity will be maintained as expected.

This stuff is very tricky, and something I’ve spent a fair amount of time wrestling with, though only in other engines. It’s not an easy problem to solve.

Unfortunately, my last long posting has been deleted somehow :/.

Thank you! That would be great!

There is also an answer at answers.unrealengine.com… altough I do not quite understand how he has done it in detail…

https://answers.unrealengine.com/questions/27198/cloningmoving-parts-of-level-having-separate-physi.html

Yes, altough I guess it would be necessary to create the actor-hierachy dynamically at runtime, as traversing a complete universe in a static precalculated tree would be probably too much overhead.

Pro: Would work with given engine features, e.g. projected textures. Con: Would not work with dynamic sunlights shining on interior.

I think a perfect solution without having to write too much special-case code would be if the unreal engine would support

  • dynamically repositioning child-navmeshes without a performance penalty
  • a custom world-gravity-vector for the movement-controller, assuming the local-gravity-vector is always (0,0,1)

I would like to play with the render-transforms of an actor-tree a little bit the next days, since I also believe that an algebraic solution would work better than reacting to a changing gravity in the physic-system.

Any clues where I would have to search for the current object-to-screenspace transforms ?

Indeed.

Would it be easier to leave the ship stationary, and out of sight, while flying a proxy around?

The players move around inside the fully detailed stationary ship (with its own physics volume),
and they’d control the proxy ship through a combination of render textures (for windows and viewscreens) or switching to remote player cameras (if they get fullscreen control).

It really depends on how you are implementing the control system interaction, but this would be the first approach I’d try.

Yes, I like the idea of steering a proxy-object, as it simplifies frame-of-reference problems a lot.

It’s mainly the problem with lights which can not shine into the spaceship which currently avoid thinking further about it. You could probably clone the lights, but then you have again put too much specialized efforts into a solution ?

This could be solved fairly easily using math to calculate light vectors in the windows on the master ship, relative to the proxy ship.