void powerBarDisplayAndSetValues() { CurrentVoltOutput.text = "Current Volts: " + "\r\n" + pairVoltCurrent; voltCurrentL = myThisPlayerPairSettings.GetmyLeftVolt(); voltCurrentR = myThisPlayerPairSettings.GetmyRightVolt(); pairVoltCurrent = (voltCurrentL + voltCurrentR) / 2; if (voltMax > 0) { voltPerc = pairVoltCurrent / voltMax; } proportion200Bar = voltPerc; //so can get up to 90% of bar percBar.fillAmount = proportion200Bar; //goes up to 200% at moment hence divide by two if (proportion200Bar >= 0.9) { percBar.color = Color.cyan; } if (proportion200Bar < 0.8 && proportion200Bar >= 0.7) { percBar.color = Color.green; } if (proportion200Bar < 0.7 && proportion200Bar >= 0.5) { percBar.color = Color.yellow; } if (proportion200Bar < 0.5) { percBar.color = Color.red; } }
void Update() { //messy if (receivedMyPlayerPairSettings)//it loses its static on scene change no idea how to help it keep it { if (leftSideBar) { voltCurrent = myPPSettings.GetmyLeftVolt(); } else { voltCurrent = myPPSettings.GetmyRightVolt(); } // if using get set could just say getset //Debug.Log("mycurrentvolt is" + voltCurrent); if (iHaveTextBoxes) { CurrentVoltOutput.text = "Current Volts: " + "\r\n" + voltCurrent; //if too fast put on coroutine hundredPercVolt.text = "100 Perc: " + "\r\n" + volt100Perc; //need max here } voltPerc = voltCurrent / volt100Perc; proportion200Bar = voltPerc; //so can get up to 90% of bar //Debug.Log("proportion 200bar" +proportion200Bar); percBar.fillAmount = proportion200Bar; //goes up to 200% at moment hence divide by two if (proportion200Bar >= 0.9) { percBar.color = Color.cyan; } if (proportion200Bar < 0.8 && proportion200Bar >= 0.7) { percBar.color = Color.green; } if (proportion200Bar < 0.7 && proportion200Bar >= 0.5) { percBar.color = Color.yellow; } if (proportion200Bar < 0.5) { percBar.color = Color.red; } //reapplying alpha percBar.color = new Color(percBar.color.r, percBar.color.g, percBar.color.b, originalAlpha); } }
// Update is called once per frame void Update() { if (myThisPlayerPairSettings.GetmyLeftVolt() > voltMinActivation && myThisPlayerPairSettings.GetmyRightVolt() > voltMinActivation) { shipSelectedIndicator.color = selectedColor; myThisPlayerPairSettings.setWerePlaying(true); } else { myThisPlayerPairSettings.setWerePlaying(false); shipSelectedIndicator.color = Color.red; } }
void setArrowScaleColor() //this is havinf find object errors now too is it because changed some static in gm { totVoltThisPeriodRight += myThisPlayerPairSettings.GetmyRightVolt() - myThisPlayerPairSettings.GetmyLeftVolt(); if (totVoltThisPeriodRight < -totVoltTriggerMove) { arrowImage.color = Color.green; arrowImage.gameObject.GetComponent <RectTransform> ().localScale = new Vector3(-1 * startScaleArrow.x, startScaleArrow.y, startScaleArrow.z); } else if (totVoltThisPeriodRight > totVoltTriggerMove) { arrowImage.color = Color.green; arrowImage.gameObject.GetComponent <RectTransform> ().localScale = startScaleArrow; } else { arrowImage.gameObject.GetComponent <RectTransform> ().localScale = new Vector3((startScaleArrow.x * totVoltThisPeriodRight / totVoltTriggerMove), startScaleArrow.y, startScaleArrow.z); } }
// Update is called once per frame void FixedUpdate() { if (shipBeenSetUp != true) { return; } // needs removing but cant till got allocated screens //ive removed !isLocalPlayer if (health.currentHealth < 0) { return; } //could retag local player as local player but this may retag them for enemy too //need to find a way to tag personally and not globally //TODO restore this later so can use buttons //cycPercSpeedLeft = CrossPlatformInputManager.GetAxis("XZVector"); //cycPercSpeedRight = CrossPlatformInputManager.GetAxis("X-ZVector"); //just normalising but vectors tricky to code straight into something //leftCycVelAngleNorm = leftCycVelAngle.normalized; //rightCycVelAngleNorm = rightCycVelAngle.normalized; //leftCycVelAngle = leftCycVelAngleNorm; //rightCycVelAngle = rightCycVelAngleNorm; //was trying to do it with velocities not forces //Debug.Log("left " + cycPercSpeedLeft + "right " + cycPercSpeedRight ); // boatVector = (leftCycVelAngle*cycPercSpeedLeft+ rightCycVelAngle*cycPercSpeedRight).normalized; //boatVector = boatVector needs to fit to the current rotation?> // MovePower=MovePowerRaw; // if(cycPercSpeedLeft > 0f || cycPercSpeedRight > 0f){ //MovePower = MovePower*(1+(cycPercSpeedLeft+cycPercSpeedRight)/2 );//not acounting for angle as the angle wont change between the velocities will also mean turns at half speed // }else {MovePower = 0;} //steerForcePos = GOSteerForcePos.transform.position; //Debug.Log(" steer force pos" +steerForcePos); //having added the force at the position it doesnt do anything other than add the force as a world component //should these angles allway be added to the angle of the ship before normalised //moves in the angle of world then spin //GetComponent<Rigidbody>().AddForceAtPosition(boatVelocityRaw*MovePower, steerForcePos, ForceMode.VelocityChange); //GetComponent<Rigidbody>().AddForce(boatVector*MovePower,ForceMode.Impulse); //was using impulse due to issues with colliders but maybe can set instead of adding forwardSpeed = (ourShipsPlayerPairSettings.GetmyLeftVolt() + ourShipsPlayerPairSettings.GetmyRightVolt()) * forwardMultiplier / ourVolt100PercMax; //soemtime get not set to instance of object wonder if to do with death angularVel = (ourShipsPlayerPairSettings.GetmyLeftVolt() - ourShipsPlayerPairSettings.GetmyRightVolt()) * angVelMultiplier / ourVolt100PercMax; //torqueModifier = cycPercSpeedLeft - cycPercSpeedRight; //works but changing to velocity // Debug.Log(" forward " + Vector3.right*forwardSpeed*forwardMultiplier + " torque Mod " + torqueModifier + " torque " + torqueModifier*torqueMultiplier ); //should it try multiplying by time.delta time on my forward speed as force should be and acceleration //changed from impulse //this.gameObject.GetComponent<Rigidbody>().AddRelativeTorque(0f, torqueModifier*torqueMultiplier,0f,ForceMode.VelocityChange); //this.gameObject.GetComponent<Rigidbody>().AddRelativeForce(Vector3.right*forwardSpeed*forwardMultiplier, ForceMode.VelocityChange); //though suppost to use forces like this better no accelerations //isnt local //needs code not to always give some percent forwards otherwise there will be no turning //actually should do above anyway //not sure it likes the fixed update seems to jerk as turns //angular velocity could be what making it fall over //testing below //could change boat angle with deltatime //this.gameObject.GetComponent<Rigidbody>().angularVelocity.Set(0,angularVel,0); //im getting every frame will be faster if put in start myRigidBody.angularVelocity = transform.up * angularVel; myRigidBody.velocity = transform.right * forwardSpeed; //local or world //are both necessary - seems to work now with out either the only other change was in the start grabbing the rigidbody // transform.up.Set(0f,1f,0f); - works just with this // transform.localPosition = new Vector3(transform.localPosition.x, 0, transform.localPosition.z); }