- Home /
Question by
Tope · Mar 28, 2012 at 06:08 PM ·
javascriptgameobject
Set gameObject transperecy when fire (Javascript)
Hello!
I am trying to set the tranperency of a gameObject when I fire a bullet like:
var projectile : Rigidbody;
var speed = 20;
var tras = 1;
function Update()
{
if( Input.GetButtonDown( "Fire1" ) )
{
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
renderer.material.color.a = tras;
if (tras > 0)
{
tras = tras - 0.1;
}
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
}
}
But it doesn't work?
What should I do?
It is in JS
Comment
Your answer
Follow this Question
Related Questions
How to create an 3d game object in 300 X 250 size? 1 Answer
Assigning variables to GameObjects 2 Answers
A node in a childnode? 1 Answer
exspecting EOF, found '}'. 3 Answers
Question Concerning transform.Rotate 1 Answer