# Aim Down Sights Positioning Problem

 0 guys, i have a problem, how i make to this script "CHANGE" the x,y,z without "ADDING" the coordinate numbersexample, i put on script to change the xys of a objecty: 0.111 x: 0.111 z: 0.111and on the object have this xysy: 0.300 x: 0.300 z: 0.300the script now make thisy: 0.400 x: 0.400 z: 0.400i 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); } ``````} more ▼ asked Dec 29 '11 at 11:15 PM Marsallima 31 ● 20 ● 24 ● 25 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 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(); } } `````` more ▼ answered Dec 29 '11 at 11:36 PM Rod Green 2.9k ● 2 ● 9 ● 42 Thanks Rod, bur continue the problem :/ OBS: The code It is within object that is to be moved... The object not stay on the cordenates give by me :/ Dec 30 '11 at 12:47 AM Marsallima You're english isn't too clear. Can you please explain the issue more clearly? Dec 30 '11 at 12:54 AM Rod Green i'm trying to make the script move the object with the local coordinates, the script that you have gave to me, he "adds" one coordenate to another Dec 30 '11 at 01:38 AM Marsallima Technically the script I gave you 'overrides' the position to the values given - it doesn't add at all but rather sets it absolutely to the fixed world coordinates.. if you want it to set local you can do something like: `````` function Apply() { //Ajusta as cordenadas para virar "Vector3" var targetPosition : Vector3 = Vector3.Lerp(transform.localPosition, Vector3(PositionX,PositionY, PositionZ), Time.deltaTime * smoothTime); //Pega as cordenadas e faz a mudança de posição :D transform.localPosition = targetPosition; } `````` Dec 30 '11 at 01:55 AM Rod Green Well, I tested for example, put the same coordinates of the object in the script and stay on same location: D but if I change it will not properly :/ But what I'm trying to do, I move the first gun (For the position of target), I copy the coordinates and put in the script, then put the gun in the usual plac., What happens when I run "apply", the weapon is not in the right place. :/ Dec 30 '11 at 02:14 AM Marsallima add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x1274
x1171
x884
x573
x445

asked: Dec 29 '11 at 11:15 PM

Seen: 763 times

Last Updated: Dec 30 '11 at 09:49 PM