I just successfully completed a trial web version of my new Unity project. It works fine. The final deliverable however is an IOS platform game. Problem is, some of the web version code does not seem to translate to well to IOS. Here is my ‘good’ web player code.
var newball;
static var tempBasketBall :Rigidbody;
var pos :Transform[0];
var ball1 :Rigidbody;
var ball2 :Rigidbody;
var ball3 :Rigidbody;
var canControl1 = true;
var canControl2 = true;
var canControl3 = true;
var destroyTime :int = 6;
var player1 :GameObject;
var player2 :GameObject;
var player3 :GameObject;
var b1Parent :Transform;
var b2Parent :Transform;
var b3Parent :Transform;
var yVel :float;
var zVel :float;
function Start()
{
ball1 = Instantiate (tempBasketBall, pos[0].position, pos[0].rotation);
ball1.transform.parent = b1Parent;
ball2 = Instantiate (tempBasketBall, pos[1].position, pos[1].rotation);
ball2.transform.parent = b2Parent;
ball3 = Instantiate (tempBasketBall, pos[2].position, pos[2].rotation);
ball3.transform.parent = b3Parent;
}
function Update()
{
if(Input.GetButtonDown(“Player1”) && canControl1)
{
player1.animation.PlayQueued(“aim”);
}
else if(Input.GetButtonUp("Player1") && canControl1)
{
player1.animation.PlayQueued("fire");
ball1.transform.parent = null;
ball1.useGravity = true;
ball1.velocity = transform.TransformDirection(0, yVel, zVel);
MakeBall1(pos[0]);
DestroyBall(ball1);
canControl1 = false;
player1.animation.PlayQueued("idle");
}
if(Input.GetButtonDown("Player2") && canControl2)
{
player2.animation.PlayQueued("aim");
}
else if(Input.GetButtonUp("Player2") && canControl2)
{
player2.animation.PlayQueued("fire");
ball2.transform.parent = null;
ball2.useGravity = true;
ball2.velocity = transform.TransformDirection(0, yVel, zVel);
MakeBall2(pos[1]);
DestroyBall(ball2);
canControl2 = false;
player2.animation.PlayQueued("idle");
}
if(Input.GetButtonDown("Player3") && canControl3)
{
player3.animation.PlayQueued("aim");
}
else if(Input.GetButtonUp("Player3") && canControl3)
{
player3.animation.PlayQueued("fire");
ball3.transform.parent = null;
ball3.useGravity = true;
ball3.velocity = transform.TransformDirection(0, yVel, zVel);
MakeBall3(pos[2]);
DestroyBall(ball3);
canControl3 = false;
player3.animation.PlayQueued("idle");
}
}
function MakeBall1(pos)
{
yield new WaitForSeconds(1);
ball1 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
ball1.transform.parent = b1Parent;
canControl1 = true;
}
function MakeBall2(pos)
{
yield new WaitForSeconds(1);
ball2 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
ball2.transform.parent = b2Parent;
canControl2 = true;
}
function MakeBall3(pos)
{
yield new WaitForSeconds(1);
ball3 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
ball3.transform.parent = b3Parent;
canControl3 = true;
}
function DestroyBall(ball:Rigidbody)
{
yield new WaitForSeconds(destroyTime);
Destroy(ball.gameObject);
}
I get a strange error saying add a semi colon at end when i add this code to my IOS build. Well clearly there is a semicolon there. It was suggested I get rid of the [0]…when I do that I get a, “BCE0048: Type ‘UnityEngine.Transform’ does not support slicing”. If I get delete the slicing elements in the ‘start function’ I get this error; BCE0019: ‘transform’ is not a member of ‘Object’. Removing ‘transform’ I get an error saying ‘position’ is not a member further degrading my control of the position of the instantiated new ball. How can I adapt this original code to work in IOS without giving up the position and transform of where the ball is to be cloned(the players Hand)? I butchered the code enough to make it compile, but the new ball instantiates at some arbitrary position and shoots from there, this is not acceptable. Any assistance would be greatly appreciated as I’m approaching a deadline and need to move pass this translation quirk.