Здраствуите. Сегодня столкнулся с одной проблемой . я делал игру на платформе Web player и все скрипты работали , но как только я изменил платформу на Android , сразу же выбило много ошибок 8-| Вот скрин ошибок : http://unity3d.ru/distribution/download/file.php?mode=view&id=5336 А вот сами скрипты :
Код
Platforms.js [syntax=javascript]// Platform.js // // Each platform has this script attached to it so that it will respawn when it should, disappear when it should // and generally do the things that we expect a platform to do in this type of game! // // -------------------------------------------------------------------------------
// we need to keep a reference to the player object so that we can keep tabs on the distance // between this platform and the player (so we can respawn when the platform is far away from it) private var playerGO : GameObject;
// we keep a reference to the game controller so that we can send it the occasional message, like telling it // to add score when a platform is destroyed and telling it to spawn an effect when the platform disappears private var gameControl : GameController;
// the width of the play area (used to keep the platforms within the play area - if you make the game wider, change the game width in gameController.js, as that's where we get its value from) private var gameWidth : float;
function Start () {
// set our platform to be on the correct layer gameObject.layer=9;
// grab a reference to our game controller script gameControl=GameObject.FindObjectOfType(GameController);
// grab the game width from the gameController.js instance gameWidth=gameControl.gameWidth;
}
function SetPlayer(playerObj : GameObject){ // store a reference to our player's gameObject playerGO=playerObj; }
function Update () {
// here we check the distance between this platform and the player on the y axis. if it's too much, we // move this platform above the player giving the illusion that there are platforms that go on forever // above it if(playerGO!=null) theY=playerGO.transform.position.y;
if((transform.position.y-theY)<-9){ // this platform is out of range, so lets respawn it respawnPlatform(); }
// when the player hits the platform, we move it off screen transform.position.x=50;
}[/syntax]
GameController.js [syntax=javascript][syntax=javascript]// gameController.js // // the gameController is the center of the game - it's where all the other scripts meet and chat // as well as the main script where scores are made and stored and all of the games main objects // get created
public var playerPrefab : GameObject; public var platformPrefab : GameObject; public var backgroundGFX : GameObject; public var getReadyMessage : GameObject; public var goMessage : GameObject; public var platformParticles : GameObject; public var gameOverMenu : gameover_GUI; public var scoreUIobj : GUIText; public var numberOfPlatforms : int = 4; public var enableBackgroundScrolling : boolean = true;
// MAKE SURE TO SET THE GAME WIDTH IF YOU CHANGE THE WINDOW SIZE!!!!! // all other scripts get their cue from this number. if you don't change it here, the platforms won't reach // the edges and the player won't either!
private var startPosition : Vector3 = Vector3(0,-3.211473,0);
private var gameScore : int; private var playerGO : GameObject; private var theCam : SmoothFollow;
private var platParent : Transform; private var platPos : Vector3;
private var GOsToClear : ArrayList;
function Start () {
initGame();
}
function LateUpdate () {
if(enableBackgroundScrolling){ // we scroll the texture on the background based on the height of the camera, so that it looks as // though we're moving up through the stars backgroundGFX.renderer.material.SetTextureOffset ("_MainTex", Vector2 (0.0, theCam.transform.position.y*0.005) ); }
}
function showGoMessage() {
// displays the 'GO!' message at the start of the game getReadyMessage.SetActiveRecursively(false); goMessage.SetActiveRecursively(true);
// move our camera out from the player theCam.setBackDistance(10);
}
function startGame() {
// tell our player it can now move playerGO.SendMessage("gameStart");
// hide the 'go!' message goMessage.SetActiveRecursively(false);
}
function initGame() {
// prepare an arrayList to store references to our platforms in. we do this so that when the // game ends we have a list of objects to destroy so that we can restart the game without // having to reload the scene GOsToClear=new ArrayList();
// Start is called automatically by the engine. Here, we do our init for the game createPlayer(startPosition); createPlatforms();
// find our camera script (SmoothFollow.js) theCam = GameObject.FindObjectOfType(SmoothFollow);
// tell our camera script to follow our player theCam.setTarget(playerGO.transform);
// set our camera distance from the player to be close up at the start of the game theCam.setBackDistance(6);
// hide any messages and our game over menu getReadyMessage.SetActiveRecursively(true); goMessage.SetActiveRecursively(false);
// hide our game over menu gameOverMenu.enabled=false;
// schedule calls to swap the GET READY message for a GO message and to start the game in 2.5 secs Invoke("showGoMessage",1.5); Invoke("startGame",2.5);
// and zero our score at the start of the game, of course gameScore=0;
scoreUIobj.text="SCORE 0";
}
function restartGame() {
// clear out the models we no longer need for(var i = 0; i<GOsToClear.Count; i++){ Destroy(GOsToClear[i]); } // everything to start a game happens in initGame() initGame();
}
function createPlayer (aStartPos : Vector3) {
// we use instantiate to 'create' an instance of our player prefab at the start position passed in // to this function, then we name it 'player' playerGO=Instantiate(playerPrefab,aStartPos,Quaternion.identity); playerGO.name="Player"; // add our player gameObject to the arraylist containing objects to be cleared when resetting the game GOsToClear.Add(playerGO); }
// here we will instantiate a bunch of platforms and place them at random x positions for(var i = -1; i<numberOfPlatforms; i++){ // choose some random positioning for the platform platPos=new Vector3(Random.Range(-3,3),Random.Range(i*4,(i*4)+2),0); // instantiate the platform aPlat = Instantiate(platformPrefab,platPos,Quaternion.identity); // name our platform 'Platform' and its ID number aPlat.name="Platform"+i; // make the platform a child of our 'Platforms' empty GameObject, just to be neat really aPlat.transform.parent=platParent; // now tell the platform who our player is, so that it can track the distance from itself and the // player and respawn above the player once it gets out of range. That way, we create an infinate // player field going forever up and up... aPlat.SendMessage("SetPlayer",playerGO); // add a reference to our arraylist to be cleared out when resetting the game GOsToClear.Add(aPlat); } }
function addScore(amount : int) {
// our platform objects call here when the player jumps on them for the first time. the platforms // can pass any score amount in and it will be added to the players score gameScore+=amount; scoreUIobj.text="SCORE "+gameScore.ToString();
}
function endGame() {
// store the games final score in a prefs file, so that we can switch scenes and pick it up to // display on the 'game over' screen. PlayerPrefs.SetInt("finalScore",gameScore);
// set a variable so that we can easily tell when the game is over gameOver=true;
// tell the player to lock down movement etc., as the game is ending playerGO.SendMessage("gameEnd");
// schedule the game over menu to appear 3 seconds from now Invoke("gotoGameOver",3);
}
function gotoGameOver(){ gameOverMenu.enabled=true; }
function doParticles(pType : int, aPos : Vector3){
switch(pType){ case 1: Instantiate(platformParticles,aPos,Quaternion.identity); break; }
}[/syntax][/syntax]
Помогите пожалуйста 8-| . Буду рад любому ответу . Help for noob
Сообщение отредактировал vegitto - Пн, 02 Дек 2013, 23:13