- Home /
What is the problem with my script and how to fix it??
I am new to coding and unity,I got this script from tutorials.Unity3d says
There are inconsistent line endings in the 'Assets/MissileLauncher.js' script. Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.
var Projectile : Rigidbody;
var speed = 20;
function Update ()
{
if( Input.GetButtonDown( "Fire1" ) )
{
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.postion, transform.rotation )
instantiatedProjectile.velocity =transform.TransformDirection( Vector3( 0, 0, speed ) )
Physics.IgnoreCollision( instantiatedProjectile. collider,transform.root.collider )
}
}
I would recommend to first learn program$$anonymous$$g. Even though you could learn using Unity, it is better to get the basics from a common usage tutorial. Your issue here is that you are missing the semi-colon at the end of each command. The semi-colon tells the compiler that it has reach the end of a command.
var instantiatedProjectile : Rigidbody = Instantiate( projectile, transform.postion, transform.rotation );
But now it would take about a month to explain that commands take a semi-colon but statements or function declaration,...,do not. How to use a loop, class declarations and so on...Get a tutorial or a book for all that.
Can u give me some links to good tutorials nd which one should i learn - c# or javascript
Answer by Althaen · Nov 05, 2012 at 06:36 AM
Your problem is quite simple. But it's the simple things that get you.
I fixed your problem. You had a colon in a place you're supposed to place an equals sign and you don't need that second Rigidbody part. Also you MUST place semicolons (;) after a statement. This is how it should look.
var Projectile : Rigidbody;
var speed = 20;
function Update ()
{
if( Input.GetButtonDown( "Fire1" ) )
{
var instantiatedProjectile = Instantiate( projectile, transform.postion, transform.rotation);
instantiatedProjectile.velocity = transform.TransformDirection(Vector3(0, 0, speed));
Physics.IgnoreCollision(instantiatedProjectile.collider,transform.root.collider);
}
}
Your answer

Follow this Question
Related Questions
Flying object x value for position keeps resetting itself 0 Answers
How to make animations only play with script? 1 Answer
My weapon takes damage. help... 1 Answer
When I kill one enemy, they all die? 0 Answers
Playerprefs save player position 3 Answers