- Home /
Question by
joeybubble1 · Apr 01, 2012 at 03:46 PM ·
positionvector3distance
Change the "y" of a variable
Hello, like it says in the title, is it possible to change the y of a variable. Current i have it like this
Cam.position += Vector3.up * Height;
i have a cam variable ( in C#) and a Height variable.
but what i have doesnt really work to well
is it possible for something like this?
Cam.position.y = Height;
Cheers :)
Comment
Answer by TowerOfBricks · Apr 01, 2012 at 03:47 PM
Cam.position is a property, so you cannot edit .y directly unfortunately. This is what you have to do
Vector3 pos = Cam.position;
pos.y = Height;
Cam.position = pos;
In Javascript (Unityscript) they found a workaround, but in C# you have to do like this.
Your answer
Follow this Question
Related Questions
how do i fix my script in the content below? 0 Answers
Position on a Vector3 at specific distance 1 Answer
Return to Start Position 1 Answer
Vector3.Project, how to? 2 Answers
Distance won't work 1 Answer