Hey guys!
I got a problem. Unity tells me always to convert the string to UnityEngine.Transform, but I don’t know how to do that.
Here is my code:
using UnityEngine;
using System.Collections;
public class PlayerName : MonoBehaviour {
public string playerName;
private bool iAmOnTheRedTeam = false;
private bool iAmOnTheBlueTeam = false;
private int mynewname;
void Start ()
{
if(networkView.isMine == true)
{
GameObject spawnManager = GameObject.Find("SpawnManager");
SpawnScript spawnScript = spawnManager.GetComponent<SpawnScript>();
GameObject joy_move = GameObject.Find ("Joy_move");
Joystick joystick = joy_move.GetComponent<Joystick>();
if(spawnScript.amIOnTheRedTeam == true)
{
iAmOnTheRedTeam = true;
}
if(spawnScript.amIOnTheBlueTeam == true)
{
iAmOnTheBlueTeam = true;
}
if(iAmOnTheBlueTeam == true || iAmOnTheRedTeam == true) {
mynewname = int.Parse(playerName);
System.Convert.ToDouble(playerName);
foreach(PlayerName) {
joystick.PlayerRed = playerName;
}
}
else
{
enabled = false;
}
}
trying to Access this code:
using UnityEngine;
using System.Collections;
public class Joystick : TouchLogicOld
{
public Transform PlayerRed = null;
}
I want to convert the value of “null” into playerName.
Pls help me!
thanks