mirror of
https://github.com/Mukheem/TwinTurbine.git
synced 2025-05-08 08:00:34 +02:00
Rotation references issue working single user
Co-Authored-By: ZeinabBF <145973209+ZeinabBF@users.noreply.github.com>
This commit is contained in:
parent
08d350dd7c
commit
5c387c5f99
Assets
@ -95,7 +95,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
|
|||||||
avatar = GameObject.FindGameObjectWithTag("Avatar");
|
avatar = GameObject.FindGameObjectWithTag("Avatar");
|
||||||
audioControllerScript = avatar.GetComponent<AudioController>();
|
audioControllerScript = avatar.GetComponent<AudioController>();
|
||||||
audioControllerScript.fn_call_AudioNarration2();
|
audioControllerScript.fn_call_AudioNarration2();
|
||||||
|
Debug.Log("Button is Clicked");
|
||||||
}
|
}
|
||||||
|
|
||||||
[PunRPC]
|
[PunRPC]
|
||||||
|
@ -42,10 +42,10 @@ public class WebSocketController : MonoBehaviour
|
|||||||
};
|
};
|
||||||
ws.OnMessage += (sender, e) =>
|
ws.OnMessage += (sender, e) =>
|
||||||
{
|
{
|
||||||
Debug.Log("Received message: " + e.Data);
|
//Debug.Log("Received message: " + e.Data);
|
||||||
//Debug.Log();
|
//Debug.Log();
|
||||||
voltageValue = e.Data.Split(':')[1].ToString();
|
voltageValue = e.Data.Split(':')[1].ToString();
|
||||||
Debug.Log(voltageValue);
|
// Debug.Log(voltageValue);
|
||||||
//Voltage:180.0
|
//Voltage:180.0
|
||||||
if (e.Data.Equals("Start Narration", StringComparison.OrdinalIgnoreCase)){
|
if (e.Data.Equals("Start Narration", StringComparison.OrdinalIgnoreCase)){
|
||||||
// narrationControllerScript.startNarration = true;
|
// narrationControllerScript.startNarration = true;
|
||||||
|
@ -3,12 +3,12 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Windturbine : API
|
public class Windturbine : MonoBehaviour
|
||||||
{
|
{
|
||||||
float angle;
|
float angle;
|
||||||
public float speed;
|
public float speed;
|
||||||
//private API apiScript;
|
private API apiScript;
|
||||||
//private GameObject GUIdataGameObject;
|
private GameObject GUIdataGameObject;
|
||||||
PhotonView photonView;
|
PhotonView photonView;
|
||||||
|
|
||||||
public float startRotationY = 0f;
|
public float startRotationY = 0f;
|
||||||
@ -21,8 +21,8 @@ public class Windturbine : API
|
|||||||
{
|
{
|
||||||
angle = Random.Range(0.0f, 120.0f);
|
angle = Random.Range(0.0f, 120.0f);
|
||||||
speed = Random.Range(75.0f, 86.0f);
|
speed = Random.Range(75.0f, 86.0f);
|
||||||
//GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
|
GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
|
||||||
//apiScript = GUIdataGameObject.GetComponent<API>();
|
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.
|
//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); ;
|
GameObject.FindGameObjectWithTag("map").transform.SetParent(null); ;
|
||||||
@ -35,11 +35,13 @@ public class Windturbine : API
|
|||||||
photonView = PhotonView.Get(this);
|
photonView = PhotonView.Get(this);
|
||||||
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
photonView.RPC("RPC_WT_Turn", RpcTarget.All);
|
||||||
|
|
||||||
if(turn_WT_on_Y_Axis) //From Base class
|
if(apiScript.turn_WT_on_Y_Axis) //From Base class
|
||||||
{
|
{
|
||||||
|
Debug.Log("FLAG IS TRUE");
|
||||||
WT_TurnOnIts_Y_Axis();
|
WT_TurnOnIts_Y_Axis();
|
||||||
turn_WT_on_Y_Axis = false;
|
apiScript.turn_WT_on_Y_Axis = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to turn the 'Turbine blades' as per the SPEED of wind that is fetched from API
|
// Method to turn the 'Turbine blades' as per the SPEED of wind that is fetched from API
|
||||||
@ -48,7 +50,7 @@ public class Windturbine : API
|
|||||||
{
|
{
|
||||||
//Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
|
//Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
|
||||||
transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle);
|
transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle);
|
||||||
angle += Time.deltaTime * (latestWS * 10); // as the value we are fetching could not turn the blades completely, Multiplying the value we are fetching from API by 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.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ public class Windturbine : API
|
|||||||
public void RPC_WT_TurnOnIts_Y_Axis()
|
public void RPC_WT_TurnOnIts_Y_Axis()
|
||||||
{
|
{
|
||||||
Debug.Log("Rotate On it's Y-Axis");
|
Debug.Log("Rotate On it's Y-Axis");
|
||||||
endRotationY = latestWD;
|
endRotationY = apiScript.latestWD;
|
||||||
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
|
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user