- Home /
Can someone explain the difference??
hey guys i was wondering if you could clear something up for me. Basically its for the following lines below i would be really great full if you could help me :)
Line 1
Code in Java :
OriginalRotation = XQuaternion = Quaternion.AngleAxis (RotationX , Vector3.up);
Code In C Sharp :
Quaternion XQuaternion = Quaternion.AngleAxis(RotationX, Vector3.up);
Now the question is in my Java script i created a variable on the top called "var OriginalRotation" and defined it as a Quaternion. Now in the Java Script you can see i have used the OriginalRotation and then defined a XQuaternion with in it and then set the AngleAxis. Now i tried the same in C but it would not allow me to place the variable before it and then define the X angle. it gave me this message
error code:
Assets/FPSScripts/FpsMouseLookCSharp.cs(56,17): error CS0118: FpsMouseLookCSharp.OriginalRotation' is a
field' but a `type' was expected
now why is that ????
Question 2:
Jave code :
static function ClampAngle (Angle, min, max): float {
C sharp Code:
public static float ClampAngle (float Angle, float Min, float Max){
the question here is why is it that in java it allowed me to use static function and then the define the angles and the fallowed by the type it is which is float. but in C sharp i had to change this to the following line shown in the C sharp line of code. Why is this ?
i would be really great full if someone could really answer this for me thank you very much in advance MCHALO :)
i know i cant be bother to write java script im sure people will understand
Answer by Dasinf · May 14, 2011 at 09:12 PM
Hello,
I believe both of your problems would be best answered if you got familiar with the C# syntax. Spend a few hours doing some simple online tutorial and I think you will avoid a lot of future problems like this.
Short pointers to both problems:
1. In JS you define the type (a string in this example) of a variable by writing...
var variableName : string
...where in C# you would simply write...
string variableName
That's why your C# is giving an error, you are trying to use a wrong syntax.
2. Again, JS and C# use a different syntax. You simply write the same thing in a different way. Learning the basic syntax of C# is really easy and you can do it in an evening if you want to.
Hope that helps, -T
lol i know who to do that lol thanks any ways you helped :)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Is something wrong with Boo? 4 Answers
Read objects like in Penumbra 1 Answer
Camera Effect + Translating US to C# 3 Answers