本文整理汇总了C#中Vessel.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.Translate方法的具体用法?C# Vessel.Translate怎么用?C# Vessel.Translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.Translate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: teleportToDockingPort
// will only work for short distances (ie. less than 50km)
// will rip the ship into little pieces if the distance is much bigger
/*static public void teleportToVessel (Vessel vessel, Vessel targetVessel, float d)
{
Vector3 j = Util.nextVector3 ().normalized * d;
Vector3 targetPos = targetVessel.orbit.pos + j;
Vector3 relPos = targetPos - vessel.orbit.pos;
if (relPos.magnitude > 50000) {
UnityEngine.Debug.Log ("TeleporterLite: warning: distance > 50km");
}
// teleport & match velocity
if (vessel.packed == false) {
UnityEngine.Debug.Log ("teleportToVessel unpacked " + relPos.magnitude.ToString ("F1"));
vessel.Translate(Util.reorder (relPos, 132));
vessel.GoOnRails ();
vessel.orbit.vel = targetVessel.orbit.vel;
vessel.GoOffRails ();
} else {
UnityEngine.Debug.Log ("teleportToVessel packed " + relPos.magnitude.ToString ("F1"));
vessel.SetPosition(targetVessel.transform.position + j);
vessel.orbit.vel = targetVessel.orbit.vel;
}
}*/
public static void teleportToDockingPort(Vessel vessel, Part vesselPort, Part targetPort, float distance)
{
// check orientation
Vector3 rp = Vector3.zero;
Vector3 euler = Vector3.zero;
float d = 0;
Util.getDockRelPosAndAtt(vesselPort, targetPort, out rp, out d, out euler);
float roll = euler.y;
euler.y = 0;
if (Util.maxElement (euler) > 5) {
UnityEngine.Debug.Log ("TeleporterLite: incorrect orientation!");
return;
}
Vector3 dockPos = vesselPort.transform.position + vesselPort.transform.TransformDirection (new Vector3 (0, Util.getDockPosY(targetPort) + 1 + distance, 0));
Vector3 relDockPos = targetPort.transform.position - dockPos;
if (relDockPos.magnitude > 500) {
UnityEngine.Debug.Log ("TeleporterLite: distance > 500m");
return;
}
// teleport
vessel.Translate(relDockPos);
// match velocity
vessel.GoOnRails();
vessel.orbit.vel = targetPort.vessel.orbit.vel;
vessel.GoOffRails();
}