Pergunta

I think I'm beginning to like this coding stuff. Anyway in my current Shooting Gallery project I have a JavaScript question. I'm building in Unity3d and I get a "transform" is not a member of "Object" error on the code inserted below.

var newball;
static var tempBasketBall :Rigidbody;
private var canFire = true;
var pos :Transform[];
var ball1 :Rigidbody;
var canControl1 = true;
var destroyTime :int = 6;
var player1 :GameObject;
var b1Parent :Transform;

var yVel :float;
var zVel :float;

function Start()
{
    ball1 = Instantiate (tempBasketBall, pos[0].position, pos[0].rotation);
    ball1.transform.parent = b1Parent;
}

function Update() { 
    if(Input.GetButton("Fire1"))
        animation.PlayQueued("fire", QueueMode.PlayNow);   
}

function TapFunction() {
    animation.PlayQueued("fire", QueueMode.PlayNow);
    player1.animation.PlayQueued("fire");
    ball1.transform.parent = null;
    ball1.useGravity = true;
    ball1.velocity = transform.TransformDirection(0, yVel, zVel);
    MakeBall1(pos[0]);
    canControl1 = false;
    player1.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;
}

The error is in the MakeBall function at the end. To my untrained mind, it seems I established the transform in the start function. As usual any assistance and shared knowledge will be tremendously appreciated.

Foi útil?

Solução

Transform(you are passing as argument an onject of this tipe) does not have a "transform" member,you should use pos.position

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top