I tried to translate a script from C# to UnityScript (javascript?).
The C# code works perfect… but my “translation” throws this error:
“Cannot Convert ‘PlayerDataClass’ to ‘void’”
Surely I made something wrong in the “translation” and I don’t know what it is…
The original code in C#:
public class PlayerDataClass {
public int networkPlayer;
public string playerName;
public int playerScore;
public string playerTeam;
public PlayerDataClass Constructor() {
PlayerDataClass capture = new PlayerDataClass();
capture.networkPlayer = networkPlayer;
capture.playerName = playerName;
capture.playerScore = playerSocre;
capture.playerTeam = playerTeam;
return capture;
}
}
My UnityScript translation:
class PlayerDataClass {
var networkPlayer : int;
var playerName : String;
var playerScore : int;
var playerTeam : String;
function PlayerDataClass() {
var capture : PlayerDataClass = new PlayerDataClass();
capture.networkPlayer = networkPlayer;
capture.playerName = playerName;
capture.playerScore = playerScore;
capture.playerTeam = playerTeam;
return capture;
}
}
“return capture” is where the console tells me it’s wrong.
Thanks in advance to anyone willing to help me.