|
ok i jsut need to move my camera up a few y positions example transform.position.y = transform.position.y +90; Whats wrong with that? if transform is the camera
(comments are locked)
|
|
You could try a tralslation instead. The Space.World ensures it moves with respect to world. For local translation just use: transform.Translate(Vector3.up * 90);
Nov 17 '10 at 09:07 AM
denewbie
Thanks for enlightening me along the way. I always went for the long version (see my answer). It just struck me how much more elegant your method is :)
Dec 06 '10 at 11:32 PM
Statement ♦♦
(comments are locked)
|
|
Why you dont easily put Exact duplicate. It doesn't work in C# either.
Dec 07 '10 at 12:26 AM
Statement ♦♦
OK, I'm geting confuse, what he wants is this but in C#???
Dec 07 '10 at 12:42 AM
Uriel_96
if you need it with C# you only need to see this page http://unity3d.com/support/documentation/ScriptReference/Transform-localPosition.html and change java script to C#
Dec 07 '10 at 12:46 AM
Uriel_96
(comments are locked)
|
|
I assume this is C# code. In C#, you can't modify struct fields on properties directly because properties return a copy of the value. It would make no sense to modify a field on a local copy. I present two options. As denewbie says:
And the long hand version:
You decide what makes the cleanest solution.
(comments are locked)
|
|
Nothing is wrong with it, though you could shorten it by writing Cannot modify the return value of 'UnityEngine.Transform.position' because it is not a variable (CS1612) Does not work in C#
Nov 17 '10 at 10:31 AM
Proclyon
Hi. for C# you cant modify a singe values you have to do it like this: transform.position = new Vector3(transform.position.x, transform.position.y+90, transform.position.z ); I find it a pain so i just just Translate
Nov 17 '10 at 11:47 AM
denewbie
You just double posted my comment here aswell and voted me down on the double answer. Isn't that slightly hypocritical? Ah well whatever. As long as it gets an accepted answer somehow. Cba flamewars
Nov 17 '10 at 12:08 PM
Proclyon
(comments are locked)
|
