I have looked around to find an answer to my problem but have not come across any, so I'm sorry if I did overlook it. My script was working in the previous versions of Unity but ever since I did a recent update (I've been absent for a while) a lot of scripts have errors written all over them. Here is the script...
The error is BCE0005: Unknown identifier: 'transform'. Located inside the shoot function, it's the line: instanceCannonball.rigidbody.AddForce (transform.forward * mechanics.force); I just don't see what's wrong with it. instanceCannonball was already declared and the variable used for adding force is declared in the class cannonballMechanics, referenced by mechanics...
Anyway, I had the same problem earlier with the error, BCE0005: Unknown identifier: 'Instantiate', located inside the shoot function, the line: instanceCannonball = GameObject.Instantiate (cannon.cannonball, cannon.spawnPos.position, cannon.spawnPos.rotation); Prior to the update I did not have to put (GameObject.) in front of Instantiate, but I checked a recent post stating the devs changed the coding. Java is more strict on defining variables. Problem is. I dont know how to edit the (transform. forward) to fix the error.
Any help or suggestions would greatly be appreciated. I'll still be attempting...
Sorry guys; I have figured out the issue. The code itself works but I received an error because the script bearing the code was named 'cannonBlast', which, is also, the name of a class inside the script.
So I guess Unity tried to access the script--which is a class itself when using java--against the class inside of the script. I figured it out when arkon tried pasting my code into an empty js file; I did the same thing--obviously changing the script name--and it worked.
Thanks a lot for your help on this one...
answered Jun 07 '12 at 08:21 AM