// Update is called once per frame void Update() { shipController playerControl = m_player.GetComponent <shipController>(); float speed = Mathf.Round(playerControl.currSpeed) * 2; m_text.text = speed.ToString() + "MPH"; }
void Update() { if (setPath) { RaycastHit hit; if (Input.GetButton("Fire1")) { readingPath = true; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Returns a ray going from camera through a screen point. if (Physics.Raycast(ray, out hit)) { if (Vector3.Distance(previousPoint, hit.point) > minTubeLength) { currentPathAnimator.addLink(previousPoint, hit.point); previousPoint = hit.point; // print("adding link"); } //transform.position = hit.point; tempPath.Add(hit.point); } } if (Input.GetButtonUp("Fire1") && readingPath) { setPath = false; readingPath = false; masterSelector.deselectAll(); path = (Vector3[])tempPath.ToArray(typeof(Vector3)); shipController currentController = masterSelector.selectedShip.GetComponent <shipController>(); currentController.move(path); tempPath.Clear(); } } }
public void deselectAll() { for (int i = 0; i < shipObjs.Length; i++) { shipController selectedController = shipObjs[i].GetComponent <shipController>(); selectedController.onDeselect(); } }
public AudioClip m_clip; //audio played on boost void OnTriggerEnter(Collider other) { m_playerObj = other.gameObject; if (other.tag == "Player" || other.tag == "Enemy") { m_shipControl = m_playerObj.GetComponent <shipController>(); m_boostTimerActive = true; other.attachedRigidbody.AddRelativeForce(Vector3.forward * 300000); AudioSource.PlayClipAtPoint(m_clip, other.transform.position, 1f); } }
void Update() { if (Input.GetKeyDown("s")) { selectorMode = true; // toggle selection mode } if (waitingUnclick && Input.GetButtonUp("Fire1")) { toggleSetPath(); } if (selectorMode) { shipObjs = GameObject.FindGameObjectsWithTag("ships"); if (Input.GetButtonDown("Fire1")) // if a click is detected { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Returns a ray going from camera through a screen point. if (Physics.Raycast(ray, out hit)) // if that click hits a collider { float prevDist = 1000000000.0f; // inf int selectedInt = -1; // null case for (int i = 0; i < shipObjs.Length; i++) // step through ships and find nearest to selection { float currentDist = Vector3.Distance(hit.point, shipObjs[i].transform.position); if (currentDist < prevDist) { selectedInt = i; prevDist = currentDist; } } selectedShip = shipObjs[selectedInt]; selectedShip.GetComponent <pathAnimator>(); shipController selectedController = shipObjs[selectedInt].GetComponent <shipController>(); deselectAll(); selectedController.onSelect(); selectorMode = false; waitingUnclick = true; } } } }
void ConditionUpdate() { if (isThePlayer()) { pilot = shipController.player; } switch (condition) { case shipCondition.waiting: if (eHP > 0) { //if (throttle == 0) condition = shipCondition.active; //else // condition = shipCondition.anchored; } else { condition = shipCondition.dead; } break; case shipCondition.adrift: if (!WeaponsOnline()) { beDisabled(); } break; case shipCondition.disabled: beDisabled(); break; case shipCondition.dead: beDead(); break; default: condition = shipCondition.waiting; break; } }
public bool m_drive; //if allowed to drive private void Awake() { //get instance of shipcontroller m_ship = GetComponent <shipController>(); }
private Transform m_target; //current waypoint transform /* * [SerializeField][Range(0, 1)]private float m_speedAlert = 0.05f; //percent of speed at max caution * [SerializeField][Range(0, 180)]private float m_angleAlert = 50f; //angle of corner to warrant caution * [SerializeField]private float m_angleVelocityAlert = 30f; //ease off accel if spin * [SerializeField]private float m_distWander = 3f; //wander amount from target * [SerializeField]private float m_distWanderSpeed = 0.1f; //how often to change dist wander * [SerializeField][Range(0, 1)]private float m_accelWander = 0.1f;//wander of acceleration * [SerializeField]private float m_accelWanderSpeed = 0.1f; //how often to change accel wander */ void Start() //init connections { m_RB = GetComponent <Rigidbody>(); m_ship = GetComponent <shipController>(); }
private shipController m_controller; //controller instance //INIT void Start() { m_controller = GetComponent <shipController>(); }