private void noseAndVelIndicators() { readVelocity = Vector3.Lerp(readVelocity, root_rbRef.velocity, readVelLerpRate * Time.deltaTime); Camera camRef = PerspectiveManager.getPManager().mainCam; // velocity vector if (root_rbRef.velocity.magnitude > velocityVectorMinSpeed) // only show onscreen if above minspeed { drawItemOnScreen(velocityVectorRef, camRef.transform.position + readVelocity.normalized, velVectLerpRate * Time.deltaTime); // drawItemOnScreen(velVectAlt, camRef.transform.position + root_rbRef.velocity, 0.5f); //Debug.Log("Fast enough, onScreen:"); } else { // place behind screen if too slow //Debug.Log("too slow, offscreen"); drawItemOnScreen(velocityVectorRef, camRef.transform.position - camRef.transform.forward, 0.5f); //drawItemOnScreen(velVectAlt, // camRef.transform.position - camRef.transform.forward, 0.5f); } if (cnnUI.cnnOn) { // nose indicator drawItemOnScreen(noseIndicatorRef, aircraftRootObj.transform.position + aircraftRootObj.transform.forward * reticle.aimPointDist, velVectLerpRate * Time.deltaTime); } else { drawItemOnScreen(noseIndicatorRef, camRef.transform.position + aircraftRootObj.transform.forward, velVectLerpRate * Time.deltaTime); } }
void Awake() { pm = PerspectiveManager.getPManager(); flight = GetComponent <RealFlightControl>(); myFlow = GetComponent <CombatFlow>(); myRb = GetComponent <Rigidbody>(); ai = GetComponent <AI_Aircraft>(); }
// Start is called before the first frame update // Perspective is automatically enabled. This is a bit crusty. // - limits this script to ONLY be used when spawning a player void Start() { Debug.Log("PerspectiveProperties started"); PerspectiveManager pManager = PerspectiveManager.getPManager(); pManager.addCam(gameObject); pManager.enableCam(gameObject); }
void Start() { //spawnPlayer(); pm = PerspectiveManager.getPManager(); userID = PhotonNetwork.LocalPlayer.UserId; //PhotonNetwork.play }
public void setPlayerAsControllable(GameObject playerObj) { // layer 8 is localPlayer layer MoveToLayer(playerObj.transform, 8); PlayerInput_Aircraft inputRoot = playerObj.GetComponent <PlayerInput_Aircraft>(); inputRoot.enabled = true; const int localPlayerLayer = 8; inputRoot.cannons.setIgnoreLayer(localPlayerLayer); CombatFlow playerFlow = playerObj.GetComponent <CombatFlow>(); playerFlow.team = team; playerFlow.isLocalPlayer = true; // Enable flight and engine control playerObj.GetComponent <RealFlightControl>().enabled = true; playerObj.GetComponent <EngineControl>().enabled = true; // Link hud to obj hudControl hud = hudObj.GetComponent <hudControl>(); hud.setHudVisible(true); hud.linkHudToAircraft(playerObj); // Enable controllers inputRoot.cam.gameObject.SetActive(true); // camera inputRoot.cannons.gameObject.SetActive(true); // cannon inputRoot.hardpointController.gameObject.SetActive(true); // hardpoints // Save this player's camera PerspectiveManager.getPManager().mainCam = inputRoot.cam.camRef.GetComponent <Camera>(); // activate targeting computer and radar playerObj.GetComponent <Radar>().enabled = true; playerObj.GetComponent <TgtComputer>().enabled = true; inputRoot.isReady = true; // start receiving and processing input }
// Place item onto screen from world point public void drawItemOnScreen(GameObject item, Vector3 worldPosition, float lerpRate) { if (aircraftRootObj != null) { Camera camRef = PerspectiveManager.getPManager().mainCam; Vector3 screenPos = camRef.WorldToScreenPoint(worldPosition); bool onScreen = true; if (screenPos.z < 0) // if screenpos behind camera { onScreen = false; } // convert to local position on canvas -- (0,0) at center of screen // THIS FIXES UI STUTTERING DURING FRAME LAG screenPos = new Vector3(screenPos.x - Screen.width / 2, // x screenPos.y - Screen.height / 2, // y 0.0f); // z Vector3 newScreenPos; if (onScreen) { if (item.transform.localPosition.x > Screen.width) { lerpRate = 1.0f; // when returning onscreen, teleport instantly } // local position prevents ui stuttering newScreenPos = Vector3.Lerp(item.transform.localPosition, screenPos, lerpRate); } else { newScreenPos = new Vector3(Screen.width * 2, Screen.height * 2); } item.transform.localPosition = newScreenPos; } }
void Awake() { rootFlow = aircraftRootRB.GetComponent <CombatFlow>(); pManager = PerspectiveManager.getPManager(); }