Tanoda
AutopilotSystem.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System.Collections;
10using System.Collections.Generic;
11using UnityEngine;
12
13namespace Leap.Unity.Examples {
14
15 [AddComponentMenu("")]
16 public class AutopilotSystem : MonoBehaviour {
17
19
20 private float _targetSpeed = 0F;
21 private Vector3 _targetTorque = Vector3.zero;
22
23 private float _currentSpeed = 0F;
24 public float currentSpeed { get { return _currentSpeed; } }
25
26 public void IncreaseSpeed() {
27 _targetSpeed += 5F;
28 }
29
30 public void IncreaseTorque() {
31 _targetTorque += 36f * Vector3.one;
32 }
33
34 public void Stop() {
35 _targetSpeed = 0F;
36 _targetTorque = Vector3.zero;
37 }
38
39 void Update() {
40 spaceship.velocity = _targetSpeed * Vector3.forward;
41 spaceship.angularVelocity = _targetTorque;
42 }
43
44 }
45
46}
The spaceship in this example is a kinematic rigidbody with a force API, but having a rigidbody on yo...
Definition: Spaceship.cs:33