I have an error on my code. I know it’s the right rotate code but why it’s not working?
using UnityEngine;
using System.Collections;
public class asd : MonoBehaviour {
public static string Square = Bed.bed;
public GUIStyle Display;
public GameObject kahon;
public float guiPlacementX1;
public float guiPlacementY1;
void OnGUI()
{
if (GUI.Button (new Rect (Screen.width * guiPlacementX1, Screen.height * guiPlacementY1, Screen.width * .2f, Screen.height * .3f), "", Display))
{
if (int.Parse (Square) == 1)
{
GameObject asdObject = Instantiate(kahon) as GameObject;
asdObject.transform.position = new Vector3(0f, 0f, 0f);
asdObject.transform.Rotate= new Vector3(40f,0,0);
}
}
}
}
The gameobject “kahon” should be rotated 40 degrees. Just to see the side of the gameobject. The problem is that it’s not running. There is an error: Assets/asd.cs(22,53): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer
I am normally using JavaScript but it should be pretty much the same, I guess.
using UnityEngine;
using System.Collections;
public class asd : MonoBehaviour {
public static string Square = Bed.bed;
public GUIStyle Display;
public GameObject kahon;
public float guiPlacementX1;
public float guiPlacementY1;
void OnGUI()
{
if (GUI.Button (new Rect (Screen.width * guiPlacementX1, Screen.height * guiPlacementY1, Screen.width * .2f, Screen.height * .3f), "", Display))
{
if (int.Parse (Square) == 1)
{
GameObject asdObject = Instantiate(kahon) as GameObject;
asdObject.transform.position = new Vector3(0f, 0f, 0f);
asdObject.transform.Rotate(40f, 0f, 0f);
}
}
}
As said i am normally using JavaScript, but i hope this helped you, by the way the error “Assets/asd.cs(22,53): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer” is probably because you use the “int.Parse (Square)” inside the if statement, i think you gotta make a variable to store it and use the variable in the if statement instead.
I am sorry, i am used to JavaScript, i am a 14 year old boy, i just tried to help, this is just the way it would work for me in JavaScript. And i really don’t see why it shouldn’t work.