Jump to content

pixartist

Members
  • Posts

    126
  • Joined

  • Last visited

Posts posted by pixartist

  1. After playing around with it some more today, I came up with pretty much the same solution. And I also haven't got a clue what the manual lock is:)

    The mechjeb code also uses the Quaternation.Euler(90,0,0), so i gues that is the right way.

    I did find a way prevent the SAS to go mad when you set it:

    currentHeading = Quaternion.LookRotation(vessel.transform.up) * Quaternion.Euler(90,0,0);
    targetHeading = Quaternion.LookRotation(targetVector) * Quaternion.Euler(90,0,0);

    if (Quaternion.Angle(currentHeading, targetHeading) > 10)
    {
    target = Quaternion.RotateTowards(currentHeading, targetHeading, 2f);
    }
    else
    {
    target = Quaternion.LookRotation(targetHeading);
    }

    part.vessel.VesselSAS.LockHeading(target, true);

    Hope this makes sense.

    Hi, what kind of values does your "targetVector" take ? Are they basically navball values ?

  2. I know I can use

    Program.Vessel.VesselSAS.LockHeading(); to set the heading of the SAS. Now what exactly is the relationship between the Euler Angles used to construct the quaternion for the SAS heading and the actual position on the navball ? Are they relative to world space or to the body my vessel is orbiting ? What's the most elegant way to use the three values of an euler angle to set the pitch (x), yaw(y) and roll(z) relative to the object I am orbiting ? Is there maybe some "navball quaternion" which I could use to rotate my constructed quat to the correct orientation ? Thanks :)

  3. Hi, I followed the tutorials in the wiki to create a simple plugin:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using KSP;
    using UnityEngine;
    namespace KSPFlightPlanner
    {
    public class FPComputer : PartModule
    {
    private bool inEditor = false;
    public override void OnStart(StartState state)
    {

    print("FP Started instance" + state);
    if (state == StartState.Editor)
    {
    inEditor = true;

    }
    }
    public override void OnInitialize()
    {
    print("Initiated instance");
    }
    public override void OnUpdate()
    {

    if (inEditor)
    {
    GUI.Box(new Rect(100, 100, 100, 300), "Test");
    }
    }

    }
    }

    The library does not throw any errors when loading, but I can't find any output in the log files. What's wrong here ?

×
×
  • Create New...