mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-04-27 20:30:34 +02:00
Rotation of WT on its own axis works now
Co-Authored-By: Masoomeh <145902196+dalarna2022@users.noreply.github.com>
This commit is contained in:
parent
8cfc1b16ea
commit
4cc86e0a42
Assets
SharedSpatialAnchors
ThirdParty/Photon/PhotonUnityNetworking/Resources
Wind_Turbine/Scripts
ProjectSettings
@ -99,6 +99,8 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
speed: 0
|
||||
startRotationY: 0
|
||||
endRotationY: 0
|
||||
--- !u!114 &2369382148363411835
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -334,12 +336,12 @@ Rigidbody:
|
||||
m_GameObject: {fileID: 382264866490105690}
|
||||
serializedVersion: 2
|
||||
m_Mass: 100
|
||||
m_Drag: 10
|
||||
m_AngularDrag: 10
|
||||
m_Drag: 1
|
||||
m_AngularDrag: 1
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_Constraints: 94
|
||||
m_CollisionDetection: 0
|
||||
--- !u!114 &4423142984711990833
|
||||
MonoBehaviour:
|
||||
@ -536,12 +538,37 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: map_logo
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8661891273527454774, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: map
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents:
|
||||
- {fileID: -6453332735135581912, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
- {fileID: -8231463906739603765, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
- {fileID: -1201471494275974383, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
- {fileID: 2070753283667298535, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
--- !u!1 &3463145896363193287 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8661891273527454774, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
m_PrefabInstance: {fileID: 5204658001146585073}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!54 &1119216912
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3463145896363193287}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1000000
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 126
|
||||
m_CollisionDetection: 0
|
||||
--- !u!4 &4270609215839807869 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 8322344887590106764, guid: 8754aa5f3d45cec4980f02029a881f7d, type: 3}
|
||||
|
@ -44,7 +44,7 @@ public class API : MonoBehaviour
|
||||
public TextMeshProUGUI loc;
|
||||
public TextMeshProUGUI windSpeedValue;
|
||||
private float LatestT;
|
||||
private float latestWD;
|
||||
public float latestWD = 0.0f;
|
||||
public float latestWS;
|
||||
private String windDirectionInDirectionTerms;
|
||||
private string unit;
|
||||
@ -54,7 +54,7 @@ public class API : MonoBehaviour
|
||||
PhotonView photonView;
|
||||
private GameObject avatar;
|
||||
private AudioController audioControllerScript;
|
||||
|
||||
public bool turn_WT_on_Y_Axis = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@ -151,6 +151,7 @@ public void ExtractDataFromJson(string json)
|
||||
windDirectionInDirectionTerms = GetWindDirection(latestWD);
|
||||
//windDirValue.SetText(latestWD.ToString());
|
||||
webSocketControllerScript.ws.Send(latestWD.ToString()+":take input");
|
||||
Debug.Log(latestWD.ToString()+" - Degrees sent to ESP");
|
||||
}
|
||||
if (point.name == "t")
|
||||
{
|
||||
@ -176,6 +177,7 @@ public void ExtractDataFromJson(string json)
|
||||
temperatureValue.SetText(locationTemperature);
|
||||
loc.SetText(location);
|
||||
windSpeedValue.SetText(windSpeed);
|
||||
turn_WT_on_Y_Axis = true; // flag set to true so that WT can rotate on it's Y axis.
|
||||
}
|
||||
[PunRPC]
|
||||
public void RPC_VoltageUpdate(String voltageGenerated)
|
||||
|
@ -55,6 +55,7 @@ MonoBehaviour:
|
||||
- RPC_WT_Turn
|
||||
- RPC_startAudioNarration1
|
||||
- RPC_startAudioNarration2
|
||||
- RPC_WT_TurnOnIts_Y_Axis
|
||||
DisableAutoOpenWizard: 1
|
||||
ShowSettings: 1
|
||||
DevRegionSetOnce: 1
|
||||
|
@ -10,6 +10,12 @@ public class Windturbine : MonoBehaviour
|
||||
private API apiScript;
|
||||
private GameObject GUIdataGameObject;
|
||||
PhotonView photonView;
|
||||
|
||||
public float startRotationY = 0f;
|
||||
public float endRotationY;
|
||||
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@ -17,23 +23,66 @@ public class Windturbine : MonoBehaviour
|
||||
speed = Random.Range(75.0f, 86.0f);
|
||||
GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
|
||||
apiScript = GUIdataGameObject.GetComponent<API>();
|
||||
|
||||
//THis condition is to detach the map with the Wind turbine after Instantiating. This helps the map stick to the ground when the turbine rotates.
|
||||
GameObject.FindGameObjectWithTag("map").transform.SetParent(null); ;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
photonView = PhotonView.Get(this);
|
||||
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
||||
|
||||
if(apiScript.turn_WT_on_Y_Axis)
|
||||
{
|
||||
WT_TurnOnIts_Y_Axis();
|
||||
apiScript.turn_WT_on_Y_Axis = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to turn the 'Turbine blades' as per the SPEED of wind that is fetched from API
|
||||
[PunRPC]
|
||||
public void RPC_WT_Turn()
|
||||
{
|
||||
Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
|
||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle);
|
||||
angle += Time.deltaTime * (apiScript.latestWS * 10);
|
||||
angle += Time.deltaTime * (apiScript.latestWS * 10); // as the value we are fetching could not turn the blades completely, Multiplying the value we are fetching from API by 10.
|
||||
|
||||
}
|
||||
|
||||
public void WT_TurnOnIts_Y_Axis()
|
||||
{
|
||||
photonView = PhotonView.Get(this);
|
||||
photonView.RPC("RPC_WT_TurnOnIts_Y_Axis", RpcTarget.All);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
public void RPC_WT_TurnOnIts_Y_Axis()
|
||||
{
|
||||
Debug.Log("Rotate On it's Y-Axis");
|
||||
endRotationY = apiScript.latestWD;
|
||||
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
|
||||
}
|
||||
|
||||
// Method to turn the 'Turbine' on its Y axis as per the DIRECTION of wind that is fetched from API
|
||||
IEnumerator RotateObject(float startAngle, float endAngle, float duration)
|
||||
{
|
||||
yield return new WaitForSeconds(2f);
|
||||
float timeElapsed = 0f;
|
||||
Quaternion startRotation = Quaternion.Euler(0, startAngle, 0);
|
||||
Quaternion endRotation = Quaternion.Euler(0, endAngle, 0);
|
||||
|
||||
while (timeElapsed < duration)
|
||||
{
|
||||
transform.parent.gameObject.transform.rotation = Quaternion.Lerp(startRotation, endRotation, timeElapsed / duration);
|
||||
timeElapsed += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
// Ensure the rotation exactly matches the end rotation at the end
|
||||
transform.parent.gameObject.transform.rotation = endRotation;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ TagManager:
|
||||
- WindTurbine
|
||||
- GUIData
|
||||
- Avatar
|
||||
- map
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
Loading…
x
Reference in New Issue
Block a user