Jump to content

Move unpacked vessels


Recommended Posts

Hi.

I'm trying to move NON packed vessels in a multiplayer mod that I'm making. The issue is that the vessel shakes horribly and I don't know what might be happening.

I don't have a problem doing it with packed vessels but I think that the flight integrator is messing with me when the vessel is unpacked and I don't know what parts should I touch to do so.

The full code: https://github.com/DaggerES/LunaMultiPlayer/blob/master/Client/Systems/VesselPositionAltSys/VesselPositionAltUpdate.cs#L153

Rotation = new Quaternion(rot[0], rot[1], rot[2], rot[3]);
Position = Body.GetWorldSurfacePosition(lat, lon, alt);

Vessel.checkSplashed();
Vessel.checkLanded();

Vessel.vesselTransform.rotation = Rotation;
Vessel.vesselTransform.position = Position;
Vessel.SetRotation(Rotation, true);
Vessel.SetPosition(Position, false);
Vessel.latitude = lat;
Vessel.longitude = lon;
Vessel.altitude = alt;

foreach (var part in Vessel.parts)
	part.ResumeVelocity();

Hopefully someone can help me with this, I feel like I'm close to finish this multiplayer mod but the movement is very jerky and I don't know what parts should I look at.

Edited by Dagger
Link to comment
Share on other sites

I think I've found a solution...

1: Subscribe to onVesselPrecalcAssign

2: When it's triggered, assign your customVesselPrecalc (that inherits from VesselPrecalculate) class to the vessel that is being created

3: Assign that vessel to your customVesselPrecalc (supposedly this shoudn't be needed but otherwise precalc.vessel is null)

4: Do an override of MainPhysics and assign the received transform pos and rot before calling base.MainPhysics

Link to comment
Share on other sites

Hi @sarbian

Another option that I saw is what principia uses. Would it be more compatible with other mods?

1- It runs a function in the TimingManager.obsenceearly and sets the vessel.precalc.enabled=false

2- In another function in TimingManager.Onprecalc it calls the vessel.SetPosition. Then it sets precalc.enabled=true and calls precalc.MainPhysics

 

 

Edited by Dagger
Link to comment
Share on other sites

2 hours ago, Dagger said:

Hi @sarbian

Another option that I saw is what principia uses. Would it be more compatible with other mods?

1- It runs a function in the TimingManager.obsenceearly and sets the vessel.precalc.enabled=false

2- In another function in TimingManager.Onprecalc it calls the vessel.SetPosition. Then it sets precalc.enabled=true and calls precalc.MainPhysics

 

 

Principia works properly with the other mods so I guess this would work. Good luck dealing with the timing mess however.

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...