I’m currently trying to do a basketball game where the basketball instantiates at a certain position after the player presses the “shoot” key. The problem is I get this error message when compiling ‘transform’ is not a member of ‘Object’
Here’s the code:
var newball;
static var tempBasketBall: Rigidbody;
var pos: Transform[];
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 yVelocity: float;
var zVelocity: float;
function Start ()
{
ball1 = Instantiate(tempBasketBall, pos[0].position, pos[0].rotation);
ball2 = Instantiate(tempBasketBall, pos[1].position, pos[1].rotation);
ball3 = Instantiate(tempBasketBall, pos[2].position, pos[2].rotation);
}
function Update ()
{
if(Input.GetButtonUp("Player1") &&canControl1)
{
ball1.useGravity = true;
ball1.velocity = transform.TransformDirection(0, yVelocity, zVelocity);
MakeBall1(pos[0]);
canControl1 = false;
}
}
function MakeBall1(pos)
{
yield new WaitForSeconds(1);
ball1 = Instantiate(tempBasketBall, pos.transform.position, pos.transform.rotation);
canControl1 = true;
}
The error points out to the instantiate section of the MakeBall1 function. How do I fix this? Help
Thanks in advance