x


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); }}}
more ▼

asked Sep 21 '11 at 12:53 PM

arashi2 gravatar image

arashi2
16 2 2 3

If you don't know how... why do you want to write it in C#?

Sep 21 '11 at 01:10 PM PrimeDerektive

Because C# is basically a better language, and @arashi2 is doing a bit of self-improvement!

Sep 21 '11 at 02:06 PM syclamoth

Bah. At this point the differences are negligible at best.

Sep 21 '11 at 02:14 PM PrimeDerektive
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

// 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);
    }
}

}

more ▼

answered Sep 21 '11 at 01:29 PM

loopyllama gravatar image

loopyllama
1.5k 1 4 18

finally it works - thank you, this helped alot

Sep 21 '11 at 04:19 PM arashi2
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4139
x3444
x225
x204
x69

asked: Sep 21 '11 at 12:53 PM

Seen: 812 times

Last Updated: Sep 21 '11 at 04:19 PM