# Aim Down Sights Positioning Problem

guys, i have a problem, how i make to this script “CHANGE” the x,y,z without “ADDING” the coordinate numbers

example, i put on script to change the xys of a object

y: 0.111 x: 0.111 z: 0.111

and on the object have this xys

y: 0.300 x: 0.300 z: 0.300

the script now make this

y: 0.400 x: 0.400 z: 0.400

i want the object move to xys give by script not add coordinate

( y: 0.111… )

Here is the code:

``````var applymode : boolean;

var smoothTime : float;

private var velocity = Vector3.zero;

var PositionX : float;

var PositionY : float;

var PositionZ : float;
``````

function Update () {

``````if(Input.GetButton("Fire2") && !applymode){

//Ajusta as cordenadas para virar "Vector3"

var targetPosition : Vector3 = transform.TransformPoint(Vector3(PositionX,PositionY, PositionZ));

//Pega as cordenadas e faz a mudança de posição :D

transform.position = Vector3.SmoothDamp(transform.position, targetPosition,velocity, smoothTime);

}

if(applymode){

//Ajusta as cordenadas para virar "Vector3"

var targetPositionH : Vector3 = transform.TransformPoint(Vector3(PositionX,PositionY, PositionZ));

//Pega as cordenadas e faz a mudança de posição :D

transform.position = Vector3.SmoothDamp(transform.position, targetPositionH,velocity, smoothTime);

}
``````

}

Try this:

``````var applymode : boolean;

var smoothTime : float = 1.0f;

private var velocity = Vector3.zero;

var PositionX : float;

var PositionY : float;

var PositionZ : float;

function Apply()
{
//Ajusta as cordenadas para virar "Vector3"

var targetPosition : Vector3 = Vector3.Lerp(transform.position, Vector3(PositionX,PositionY, PositionZ), Time.deltaTime * smoothTime);

//Pega as cordenadas e faz a mudança de posição :D

transform.position = targetPosition;
}
function Update () {

if(Input.GetButton("Fire2") && !applymode){
Apply();
}

if(applymode){

Apply();
}
}
``````