Jump to content

Timewarp Rotation Fix


skykooler

Recommended Posts

I am installing this now, but I would like two clarification:

All vessels rotate during warp, not just the currently active one

Does this mean ships that are unloaded from the physics engine will rotate as well?

it will draw ElectricCharge to maintain orientation

Will it also gain ElectricCharge from solar panels and other sources?

Ships already gain ElectricCharge from solar panels during warp in stock KSP, I believe.

I was thinking more, if my first question's answer was "yes"...

Link to comment
Share on other sites

The stock feature that speeding up game time kills rotation? That's not a feature. It's a very-exploited bug.

You may as well ask, "Why is the stock feature of no resource mining being disabled by Kethane?"

I guess I need to quote your own questions back to you so you don't get lost. Ok, here is the last few posts again...

I am installing this now, but I would like two clarification:

All vessels rotate during warp, not just the currently active one

Does this mean ships that are unloaded from the physics engine will rotate as well?

it will draw ElectricCharge to maintain orientation

Will it also gain ElectricCharge from solar panels and other sources?

Ships already gain ElectricCharge from solar panels during warp in stock KSP, I believe.
I was thinking more, if my first question's answer was "yes"...
Ok, but why would that stock feature be disabled?
The stock feature that speeding up game time kills rotation?

No. The stock feature that you just asked about... solar panels working in timewarp.

Edited by RoboRay
Link to comment
Share on other sites

I guess I need to quote your own questions back to you so you don't get lost. Ok, here is the last few posts again...

No. The stock feature that you just asked about... solar panels working in timewarp.

Only the active vessel draws power from SAS.

Link to comment
Share on other sites

I think I've encountered a bug with this mod. It appears to be multiplying the magnitude of rotation after coming out of timewarp.

In the video you can see I start out in 1X time with a small rotation, go to 50X, and back out to 1X. Each time I do this the rotation is greater. I turn on SAS and the rotation is slowly nulled, but if I turn it off, then timewarp again, I see a repeat of the same behavior of each round of timewarp increasing the rotational velocity.

Link to comment
Share on other sites

I think I've encountered a bug with this mod. It appears to be multiplying the magnitude of rotation after coming out of timewarp.

In the video you can see I start out in 1X time with a small rotation, go to 50X, and back out to 1X. Each time I do this the rotation is greater. I turn on SAS and the rotation is slowly nulled, but if I turn it off, then timewarp again, I see a repeat of the same behavior of each round of timewarp increasing the rotational velocity.

Out of curiosity, does this happen with the solar panels retracted too? Getting the vessel spinning again is sort of black magic and it might be confused as to where the center of mass of the solar panel is.

Link to comment
Share on other sites

Out of curiosity, does this happen with the solar panels retracted too? Getting the vessel spinning again is sort of black magic and it might be confused as to where the center of mass of the solar panel is.

Hmm. Let me try that out and get back to you. When I tested the mod earlier today the vessel didn't have solar panels, so you may be onto something.

On edit: Drat, that wasn't it. I just tried it out again, and got the same effect as you saw in the previous video, with and without solar panels extended.

Edited by lincourtl
Link to comment
Share on other sites

I think the mod has some problems with remembering the axises of rotation, especially if there were more than one. I could have recorded a video, but is seems pretty obvious to me. Is it confirmed? Or, it can be something in my install? I can see it clearly when I rotate a simple 3 part craft in various directions, warp it a little and when I unwarp it, it gets a rather hard kick in one direction of rotation and loses others. Looks like it gain some momentum too. Maybe, it is more visible with ships that rotate faster.

Link to comment
Share on other sites

I think the mod has some problems with remembering the axises of rotation, especially if there were more than one. I could have recorded a video, but is seems pretty obvious to me. Is it confirmed? Or, it can be something in my install? I can see it clearly when I rotate a simple 3 part craft in various directions, warp it a little and when I unwarp it, it gets a rather hard kick in one direction of rotation and loses others. Looks like it gain some momentum too. Maybe, it is more visible with ships that rotate faster.

Yeah, that's what I'm seeing too. See the video I posted above (#31). skykooler thought it might be a problem with center of mass because I had solar panels extended, but further testing on my part revealed the same behavior whether they were extended or not.

Link to comment
Share on other sites

How much of a performance hit does this have? Is low system spec performance the reason the developers didn't have this in the game?

No noticable performance hit on my laptop, which is fairly low-specced (even have Intel graphics).

Link to comment
Share on other sites

I noticed you're storing vessel rotations in the cfg file using pid. This is fine, except we can have two vessels with the same pid in two different saves. (If we make a copy of the save.) This obviously causes problems when the vessel is landed safely in one save, but in orbit and rotating madly in the other save. I just tested this with a lander on the Mun. Steps to reproduce: Make a copy of the save. In the first copy launch a craft, get into orbit (or at least above the "cannot X while about to crash" altitude), disable SAS and set the craft tumbling. Timewarp, return the Space Center, exit. Load the second save. Load the craft. Phantom force!

This is also an issue with Quick Save / Quick Load.

Would you consider keeping the records separate by save file? Perhaps by appending a name to the cfg file as AlarmClock does, or even appending the save file name to the pid you're using as a key? Perhaps keeping the timestamp in there to account for QuickSave/QuickLoad?

(Note: I've also encountered the phantom acceleration when leaving timewarp bug lincourtl reports above, though I don't have solid numbers on how fast it ended up going.)

Edited by Cydonian Monk
Link to comment
Share on other sites

No noticable performance hit on my laptop, which is fairly low-specced (even have Intel graphics).

Unlike a couple unappreciative people in this thread, I want to thank you for making this. It adds a level of immersion the game was missing for me. Hopefully you can get those last couple of quibbles worked out.

Cheers!

Link to comment
Share on other sites

Unlike a couple unappreciative people in this thread, I want to thank you for making this. It adds a level of immersion the game was missing for me. Hopefully you can get those last couple of quibbles worked out.

Cheers!

I agree; frankly it's a wonder that SQUAD hasn't addressed this yet.

It's a needed feature.

Link to comment
Share on other sites

I've tested this and can confirm that sometimes the rotation changes after timewarping. Sometimes it comes out of timewarp rotating faster than it did before, and sometimes it rotates less.

Also, this is not necessarily a problem with the mod but freely rotating parts using Infernal Robotics docking washers do not maintain their rotation during timewarp with this mod.

Other than those issues, this alpha is looking promising! Good work.

Link to comment
Share on other sites

Tried it. Love it. This mod adds a level of realism that Squad is moving away from. Specifically, it introduces the need for electric charge and/or RCS to maintain orientation. I played it for an hour or so last night and it's now a must have right beside deadly reentry.

The rotation problem is only a problem where there is rotation to amplify. So long as sas is enabled and the craft is stable before warp, I'm not having issues. It also doesn't recognize RemoteTech2's flight computer as sas, but this is really not much of a problem. You just have to remember not to warp with the flight computer in command.

Link to comment
Share on other sites

Does anyone have any ideas as to how to fix the rotation changing? The issue, as far as I can tell, is that as you can't set an angular velocity on the ship as a whole, I am applying a torque to each part when the ship comes out of timewarp to get it moving again. I think I have the right values for torque, because it works fine when a ship contains only stack mounted parts and is being rotated around its yaw axis. The problem is that any parts whose centers of mass are not in line with that of the vessel also need to have a force applied to them, whose value depends on both the direction and distance from the vessel's center. And I've been sort of guessing with the math here, because I'm not really sure what everything is (for example, do animated parts have multiple rigidbodies? I have no idea.) So if anyone has any suggestions to fix my math/physics, that would be most welcome.

Link to comment
Share on other sites

I'm totally ignorant as to how KSP/Unity models physics, so I apologize if this sounds idiotic, but is there no way to simply record the force vectors on each part when you put the ship on rails, then restore them when physics is resumed?

Does anyone have any ideas as to how to fix the rotation changing? The issue, as far as I can tell, is that as you can't set an angular velocity on the ship as a whole, I am applying a torque to each part when the ship comes out of timewarp to get it moving again. I think I have the right values for torque, because it works fine when a ship contains only stack mounted parts and is being rotated around its yaw axis. The problem is that any parts whose centers of mass are not in line with that of the vessel also need to have a force applied to them, whose value depends on both the direction and distance from the vessel's center. And I've been sort of guessing with the math here, because I'm not really sure what everything is (for example, do animated parts have multiple rigidbodies? I have no idea.) So if anyone has any suggestions to fix my math/physics, that would be most welcome.
Link to comment
Share on other sites

So I just tried this out... And man does it make some things more challenging. For example, I'm using this in conjunction with deadly re-entry and in career mode before you have the means to regenerate your batteries, and before you have RCS to perform attitude adjustments, this makes conserving your electricity so you can re-orient for re-entry absolutely paramount. Plus it's slowly but surely helping me break my habit of tapping time warp to kill rotation. I can't wait to see how far this mod goes!

Link to comment
Share on other sites

I'm totally ignorant as to how KSP/Unity models physics, so I apologize if this sounds idiotic, but is there no way to simply record the force vectors on each part when you put the ship on rails, then restore them when physics is resumed?

The thing is, parts don't have forces making them rotate; they are just rotating due to momentum. So rather than having forces, all I have is velocities. And the methods I am using are supposed to assign directly to velocities, but may very well not as I don't really know what they are doing or how Unity's physics model works.

Link to comment
Share on other sites

The thing is, parts don't have forces making them rotate; they are just rotating due to momentum. So rather than having forces, all I have is velocities. And the methods I am using are supposed to assign directly to velocities, but may very well not as I don't really know what they are doing or how Unity's physics model works.

Oh! I see now. That is problematic.

Link to comment
Share on other sites

Does anyone have any ideas as to how to fix the rotation changing? The issue, as far as I can tell, is that as you can't set an angular velocity on the ship as a whole, I am applying a torque to each part when the ship comes out of timewarp to get it moving again. I think I have the right values for torque, because it works fine when a ship contains only stack mounted parts and is being rotated around its yaw axis. The problem is that any parts whose centers of mass are not in line with that of the vessel also need to have a force applied to them, whose value depends on both the direction and distance from the vessel's center. And I've been sort of guessing with the math here, because I'm not really sure what everything is (for example, do animated parts have multiple rigidbodies? I have no idea.) So if anyone has any suggestions to fix my math/physics, that would be most welcome.

If you go about it that way, you need to use Unity's Moment of Inertia Tensor for each part. However, counterintuitively, this does not actually return a tensor but a vector containing three values. I think those are the principal moments of inertia, and if you map*those to the diagonal of a zero matrix then you will get the moment of Inertia tensor coordinatized in a principal axis basis. If you can determine what the ship's angular velocity (use the velocity you stored for the vessel at the start of time warp) is coordinatized in this principal axis basis (I am not 100% sure but I think Unity's rigidbody.transform.angularVelocity will return this). In essense, multiply this principal moment of inertia matrix and rigidbody.transform.angularVelocity will tell you what the angular momentum is.

EDIT: Actually, since you want the torque that applies this angular momentum in a single physics step, you probably want to divide the angular momentum by the fixed delta-t of the game.

Edited by tntristan12
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...