Rotation references issue working single user

Co-Authored-By: ZeinabBF <145973209+ZeinabBF@users.noreply.github.com>
This commit is contained in:
Abdul Mukheem Shaik 2024-05-28 02:39:59 +02:00
parent 08d350dd7c
commit 5c387c5f99
3 changed files with 14 additions and 12 deletions
Assets
SharedSpatialAnchors/Scripts
Wind_Turbine/Scripts

@ -95,7 +95,7 @@ public class API : MonoBehaviourPunCallbacks, IPunObservable
avatar = GameObject.FindGameObjectWithTag("Avatar");
audioControllerScript = avatar.GetComponent<AudioController>();
audioControllerScript.fn_call_AudioNarration2();
Debug.Log("Button is Clicked");
}
[PunRPC]

@ -42,10 +42,10 @@ public class WebSocketController : MonoBehaviour
};
ws.OnMessage += (sender, e) =>
{
Debug.Log("Received message: " + e.Data);
//Debug.Log("Received message: " + e.Data);
//Debug.Log();
voltageValue = e.Data.Split(':')[1].ToString();
Debug.Log(voltageValue);
// Debug.Log(voltageValue);
//Voltage:180.0
if (e.Data.Equals("Start Narration", StringComparison.OrdinalIgnoreCase)){
// narrationControllerScript.startNarration = true;

@ -3,12 +3,12 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Windturbine : API
public class Windturbine : MonoBehaviour
{
float angle;
public float speed;
//private API apiScript;
//private GameObject GUIdataGameObject;
private API apiScript;
private GameObject GUIdataGameObject;
PhotonView photonView;
public float startRotationY = 0f;
@ -21,8 +21,8 @@ public class Windturbine : API
{
angle = Random.Range(0.0f, 120.0f);
speed = Random.Range(75.0f, 86.0f);
//GUIdataGameObject = GameObject.FindGameObjectWithTag("GUIData");
//apiScript = GUIdataGameObject.GetComponent<API>();
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); ;
@ -35,11 +35,13 @@ public class Windturbine : API
photonView = PhotonView.Get(this);
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();
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
@ -48,7 +50,7 @@ public class Windturbine : API
{
//Debug.Log("WIND SPEED FROM API SCRIPT:" + apiScript.latestWS);
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()
{
Debug.Log("Rotate On it's Y-Axis");
endRotationY = latestWD;
endRotationY = apiScript.latestWD;
StartCoroutine(RotateObject(startRotationY, endRotationY, 3.5f));
}