So when i tried out this code ( I made about 90% of it myself so of course it wouldnt work ) … it doesnt work - basicly i want my gun to move to the recoil position x and y when i press fire 1 (left click) but it wont budge…
var originalPosx = -0.1600189;
var originalPosy = -0.2532201;
var recoilPosx = -0.1597214;
var recoilPosy = -0.2532201;
var dampVelocity = 0.1;
var dampVelocity2 = 0.1;
function Update (){
var recoilPosx = Mathf.SmoothDamp(Gun.transform.localPosition.x, recoilPosx, dampVelocity, .3);
var recoilPosy = Mathf.SmoothDamp(Gun.transform.localPosition.y, recoilPosy, dampVelocity, .3);
Gun.transform.localPosition.x = recoilPosx;
Gun.transform.localPosition.y = recoilPosy;
if (Input.GetButtonDown("Fire1")) {
recoilPosx = -0.159721;
recoilPosy = -0.2532063;
//dont know what to do so it resets ... and goes back to its originbal position
recoilPosx = -0.1600189;
recoilPosy = -0.2532063;
}
}
Ok i will try that
– knuckles209cp