- Home /
Question by
arashi2 · Sep 21, 2011 at 12:53 PM ·
c#javascripttranslateconvertconversion
java to C# conversion
pleas help me - don't know how to write this code in C#
var follow :GameObject;
function LateUpdate () {
var cam = GetComponent("Camera");
if(cam != null)
{
if(follow)
{
cam.transform.position = Vector3(0,0,0); }}}
Comment
If you don't know how... why do you want to write it in C#?
Because C# is basically a better language, and @arashi2 is doing a bit of self-improvement!
Bah. At this point the differences are negligible at best.
Best Answer
Answer by loopyllama · Sep 21, 2011 at 01:29 PM
// sorry about the formatting, the 1010101 button isn't working...
GameObject follow; // not assigned, will always be null
void LateUpdate()
{
Camera cam = gameObject.GetComponent() as Camera;
if(cam != null)
{
if(follow != null)
{
cam.transform.position = Vector3.zero;
// long-winded way
// cam.transform.position = new Vector3 (0.0F, 0.0F, 0.0F);
}
}
}
Your answer
Follow this Question
Related Questions
Help with conversion from javascript to c# 3 Answers
Can someone help me translate this to c#? 1 Answer
How to make this line work in C#? 1 Answer
Converting Variable to C# 1 Answer