|
hi guys, i just created a raycast script that opens a door when the hit collider hits the door. The script i made was done in java now the thing is that i now want to take this script and make the same thing in C sharp. But as soon as i tried that i came across a problem, basically in the update function in my java script i created a variable called :
now in C sharp if i try to make the same variable it wont work what is the correct way to put this right in C# here are my scripts : JAVA:
That was the Java script here is the C sharp :
So yea thats the scripts and thanks in advance :)
(comments are locked)
|
|
The way you need to declare that variable in C# is
No need for the var keyword in C#. thank you very much :)
Apr 08 '11 at 12:29 PM
MC HALO
No problem. =) Just remember in C# any variable you want to declare is
Apr 08 '11 at 12:33 PM
KeithK
yea thanks :) dude
Apr 08 '11 at 12:46 PM
MC HALO
I couldn't find an instance of var in the C# code, I checked for that the first Thing I possibly could. Am I just reading this question entirely differently ? I see 2 blocks one in Java one in C# , and they seem to be about different things, and a that raycast as the text claims is a java code bit (in my interpretation ) """Quote""" But as soon as i tried that i came across a problem, basically in the update function in my java script i created a variable called : var Hit: RaycastHit; """End Quote""" You are very correct saying don't use var in C# +1 for that
Apr 08 '11 at 12:47 PM
Proclyon
(comments are locked)
|

You have a float defined as 5, to increase readability you could use 5.0f instead. This is common practice but a choice nonetheless. (Thanks go to KeithK for spotting the error)
By the way, this is actually not Java at all; rather, it’s JavaScript (more precisely, UnityScript — Unity’s adaptation of JavaScript), which is not the same thing.