void Awake()
    {
        if (ActiveController == null)
        {
            ActiveController = this;
        }
        rb     = GetComponent <Rigidbody> ();
        rotors = new Transform[4] {
            frontLeftRotor,
            frontRightRotor,
            rearLeftRotor,
            rearRightRotor
        };
        MotorsEnabled = false;
//		UseGravity = false;
        Forward = forward.forward;
        Right   = right.forward;
        Up      = transform.up;
        CreateCameraTex();
//		transform.position = Vector3.up * 10;
        UseGravity = rb.useGravity;
//		UpdateConstraints ();
        rb.maxAngularVelocity = Mathf.Infinity;
        inputCtrl             = GetComponent <SimpleQuadController> ();
//		dot = new Texture2D ( 1, 1 );
//		dot.SetPixel ( 0, 0, Color.white );
//		dot.Apply ();
//		Debug.Log ( "it: " + rb.inertiaTensor + " itr: " + rb.inertiaTensorRotation );
//		rb.ResetInertiaTensor ();
//		rb.inertiaTensorRotation = Quaternion.identity;
//		Debug.Log ( "2 it: " + rb.inertiaTensor + " itr: " + rb.inertiaTensorRotation );
//		gameObject.SetActive ( false );
//		gameObject.SetActive ( true );
    }
示例#2
0
    void Start()
    {
        _socket = GetComponent <SocketIOComponent> ();
        _socket.On("open", OnOpen);
        _socket.On("object_detected", OnObjectDetected);
        _socket.On("object_lost", OnObjectLost);
        _socket.On("create_box_marker", OnCreateBoxMarker);
        _socket.On("delete_marker", OnDeleteMarker);
        _socket.On("error", OnError);
        _socket.On("ping", OnPing);
        inset1Tex = new Texture2D(1, 1);
        inset2Tex = new Texture2D(1, 1);
//		inset3Tex = new Texture2D ( 1, 1 );

        broadcastFrequency = 5;         // 10; //30; //60;
        control            = quad.inputCtrl;
        gimbal             = control.gimbal;
        Debug.Log("starting");
//		EmitTelemetry ();
                #if UNITY_EDITOR
        UnityEditor.EditorApplication.playmodeStateChanged += HandleCallbackFunction;
                #endif
        depthImage = gimbal.colorCam.GetComponent <RGBToDepth> ().destTex;
//		StartCoroutine ( BroadcastFunc () );
        nextBroadcast = Time.realtimeSinceStartup + 1f / broadcastFrequency;
        locker        = new object();
        lastPingTime  = Mathf.Infinity;
//		broadcastThread = new Thread ( ThreadFunc );
//		broadcastThread.Start ();
    }
 public override void OnEnter()
 {
     if (control == null)
     {
         control  = SimpleQuadController.ActiveController;
         motor    = control.controller;
         follower = control.follower;
         gimbal   = control.gimbal;
     }
 }
    void Awake()
    {
        if (!active)
        {
            enabled = false;
            return;
        }

        inputCtrl = GetComponent <SimpleQuadController> ();
        pather    = GetComponent <PathFollower> ();
    }
示例#5
0
 void Awake()
 {
     ActiveController = this;
     rb             = GetComponent <Rigidbody> ();
     rb.constraints = RigidbodyConstraints.FreezeRotation;
     if (controller == null)
     {
         controller = GetComponent <QuadMotor> ();
     }
     if (followCam == null)
     {
         followCam = camTransform.GetComponent <FollowCamera> ();
     }
 }