Okay this is my first time using javascript and unity3D to make a game. I’ve been chipping away for about a week now and i feel i’ve made good progress. I have scripted my character movement and enemy movement as well as set up a score counter. One of the first scripts i made, was a script to follow my hero around on the platforms. All week every time i run a test the camera has worked perfectly. No problems. However last night it started to shake out of controlonce my character went about 120 on the Y axis. Here is the script i am using to follow my player around:
public var Player : Transform;
function Update(){
transform.position.x = Player.position.x;
transform.position.y = Player.position.y;
if (Player.position.y < 100){
transform.position.y = 100;
}
}
So the first thing you may suggest is the shaking isbeing caused because i’ve asked the camera to sit up higher than the player if he is on the ground. That’s what i thought, and it seems straight forward, however like i said, this script has been working flawlessly for me all week and now all of a sudden if my player goes higher then 120 on the Y axis (100 is his position and his height is 20) the camera starts shaking around. Almost like it can’t decide whether it should sit at the fixed position of 100 or whether it should start following the players position. Another theory i have is that the camera is trying to position itself with a second variable, or a second instance of my Player variable. But i can’t see that anywhere in any inspector.
I think a cleaner script would be to change the if (Player.position.y < 100){
to something like if (Player.is Grounded){
but javascript doesn’t like that line.
Sorry for the wall of text, thanks for any help and advice.