- Home /
Animations are jerky? with FOV and aspect ratios
so i have a sniper rifle and my aim down sights is a combination 2 scripts, one that changes the main cameras field of view and another that plays an animation to bring the sniper to eye level. both while holding right click
the FOV works and the animation stops before it reaches eye level sometimes it will jerk and get stuck also if i have maxmize on play selected it will always jerk or any other size then 2 by 3
for the animation below
var AnimName ="scopeinsniper";
//private var resetTime = .0000000000000000;
var useBackwards = true;
function Update (){
if(useBackwards==true){
if(Input.GetMouseButtonDown(1)){
animation[AnimName].speed = 2;
//animation[AnimName].time = resetTime;
animation.Play(AnimName);
}
if(Input.GetMouseButtonUp(1)){
animation[AnimName].speed = -2;
//resetTime =animation[AnimName].time;
animation[AnimName].time = animation[AnimName].length;
animation.Play(AnimName);
for FOV
public var FOVIN :float = 35;
public var FOVSpeed :float = 5;
public var Aim : boolean = false;
public var DeffFOV : float;
public var CAM : GameObject;
function Awake(){
DeffFOV = CAM.camera.fieldOfView;
}
function Update () {
if(Input.GetMouseButtonDown(1)){
Aim = true;
} if(Input.GetMouseButtonUp(1)){
Aim = false;
}
if(Aim){
CAM.camera.fieldOfView = Mathf.Lerp(CAM.camera.fieldOfView, FOVIN , FOVSpeed * Time.deltaTime);
}
if(!Aim){
CAM.camera.fieldOfView = Mathf.Lerp(CAM.camera.fieldOfView , DeffFOV , FOVSpeed * Time.deltaTime);
}
}
Your answer
Follow this Question
Related Questions
How do I run two animations at once on the same game object? 2 Answers
Animation plays at original position? 1 Answer
Unity 3D Gun Animation Errors 1 Answer
animation not playing 0 Answers
Aiming down a gun with animation 2 Answers