- Home /
Duplicate Question
http://answers.unity3d.com/questions/303417/need-help-converting-js-to-c-3.html
[Dublicated, delete] Need help converting js to C#
I am new to Unity and i am trying to convert the CharacterControl script from the book "Unity 3 Game Development Hotshot". I have most of it but am having trouble with two things
JS - var v3_movement : Vector3 = (v3_moveDirection * f_moveSpeed) + Vector3 (0, f_verticalSpeed, 0);
C# - Vector3 v3_movement = (v3_moveDirection * f_moveSpeed) + Vector3 (0, f_verticalSpeed, 0);
The error i get is Expression denotes a `type', where a `variable', `value' or `method group' was expected
jS - public function IsGrounded () : boolean { return (c_collisionFlags & CollisionFlags.CollidedBelow); }
C# public bool IsGrounded() { return (c_collisionFlags & CollisionFlags.CollidedBelow); } the error here is Cannot implicitly convert type `UnityEngine.CollisionFlags' to `bool'
Any suggestions greatly appreciated
Cheers
just add new before Vector3
C# - Vector3 v3_movement = (v3_moveDirection * f_moveSpeed) + new Vector3 (0, f_verticalSpeed, 0);
Answer by Muuskii · Aug 17, 2012 at 04:06 PM
Vector3 v3_movement = (v3_moveDirection * f_moveSpeed) + Vector3 (0, f_verticalSpeed, 0);
In C# you need new Vector3()
Vector3 v3_movement = (v3_moveDirection * f_moveSpeed) + new Vector3 (0, f_verticalSpeed, 0);
The other line is confusing, but it looks like you're trying to access the CollisionFlags class, not an instance. It might be helpful to see the rest of the code for that line.
Follow this Question
Related Questions
how can convert this in js? 1 Answer
Trying to Convert this JS to C# 2 Answers
Need help converting js to C# 4 Answers
Js to C# convert 1 Answer
Converting JS to C# 3 Answers