Hi, Firts I ALREADY searched on the other topic like this and nothing work for me so,
I don't want this kind of answer :
http://lmgtfy.com/?q=Unity+3d+smooth+aiming+script ok ?
so my probleme is : my script don't give error and here's a bug : My weapon don't move to the camera : My camera is zooming and my crosshair is disabled but my weapon don't move : Yes I have change the X Y and Z pos of normal and scope position for test, here's my script :
#pragma strict
var Weapon : Transform;
var player : GameObject;
var zoomedFOV : float = 40;
var originalFOV : float = 60;
var ScopingXGunPos : float;
var ScopingYGunPos : float;
var ScopingZGunPos : float;
var NormalXGunPos : float;
var NormalYGunPos : float;
var NormalZGunPos : float;
var smoothTime : float = 0.3;
private var crossHairS : Crosshair;
private var targetX : float;
private var targetY : float;
private var targetZ : float;
private var velocityY : float = 0; //DON'T TOUCH THIS TO !
private var velocityZ : float = 0; //DON'T TOUCH THIS TO !
private var velocityX : float = 0; //DON'T TOUCH THIS TO !
function Start () {
//transform.localPosition = NormalPos;
crossHairS = player.GetComponent(Crosshair);
}
function Update () {
var newX : float = Mathf.SmoothDamp(Weapon.transform.localPosition.x, targetX, velocityX, smoothTime);
var newY : float = Mathf.SmoothDamp(Weapon.transform.localPosition.y, targetY, velocityY, smoothTime);
var newZ : float = Mathf.SmoothDamp(Weapon.transform.localPosition.z, targetZ, velocityZ, smoothTime);
if(Input.GetButton("Fire2")){
Camera.main.fieldOfView = zoomedFOV;
crossHairS.ShowCrosshair = false;
targetX = ScopingXGunPos;
targetY = ScopingYGunPos;
targetZ = ScopingZGunPos;
Weapon.transform.position = Vector3 (newX, newY, newZ);
}
if(!Input.GetButton("Fire2")){
Camera.main.fieldOfView = originalFOV;
crossHairS.ShowCrosshair = true;
targetX = NormalXGunPos;
targetY = NormalYGunPos;
targetZ = NormalZGunPos;
Weapon.transform.position = Vector3 (newX, newY, newZ);
}
}
Thanx.
↧