- Home /
How to move the camera depending on the score?
Thanks for reading my question...
First i am very new to scripting , i have been days reading how to move the camara how i want but nothing works exactly.
I want to move the camara position Y (9) each time the score of the game reach 7 or a multiple of seven
Example:
Score = 7 Move Camraa in Y 9
Score = 14 Move Camara in Y 9 more
Score = 21 Move Camara in Y 9 more
And so.....
The script i have, the camara move Y wen the score reach 7 but never stops , it continuously moving in Y.
Here is the script , thanks for your help.
#pragma strict
var guiHeight : GUIText;
var myCamera : GameObject;
var sum : int = 2;
private var height: int = 0 ;
function Start () {
guiHeight.text = "Height: 0";
}
function Update () {
if(Input.GetButtonDown("Fire1")){
height += 1;
guiHeight.text = "Height: " + height;
}
if( height % 700 == 7 )
{
myCamera.transform.position.y += 9;
}
}
Answer by RadioactiveTechnologies · Nov 22, 2014 at 04:58 PM
You can use this, and if you werent starting at a height of zero, just add what you're starting at to the transform changing at the end.
#pragma strict
var guiHeight : GUIText;
var myCamera : GameObject;
var sum : int = 2;
private var height: int = 0 ;
function Start () {
guiHeight.text = "Height: 0";
}
function Update () {
if(Input.GetButtonDown("Fire1")){
height += 1;
guiHeight.text = "Height: " + height;
}
if( height%7 == 0 )
{
myCamera.transform.position.y = height*9;
}
}
}
Please upvote this answer if it was helpful!
WoW!!!! you are the best!!!!
Well Got 2 Bugs but fix it.
if( height%7 == 0 )
{
myCamera.transform.position.y = height*9;
}
Bugs
$$anonymous$$y camara starting position is Y (2) , but wen i hit play it get down to (-1) (I think this is what you mean)
2.Wen Score get to 7 the camara went up to Y (62) , then wen the score get 14 the camara move to Y (125)
Solution
I Change height*9 to height+3
Bug Script myCamera.transform.position.y = height*9;
Fix Script myCamera.transform.position.y = height+3;
try using
myCamera.transform.position.y = height/7*9+2;
I forgot to make it divide by 7. That's important.
Your answer
Follow this Question
Related Questions
Can you help me understand this Camera calibration between Kinect and PS Move? 2 Answers
getting the position of player for the minimap to follow 1 Answer
How to make your character move? 7 Answers
Setting a cube to be exactly size of intersecting camera view plane 1 Answer
GUI.Button child of the camera . 0 Answers