- Home /
Snap Back?
This script which I have wrote Changes the transform of whatever the scripts attached to when the RMB is clicked, but what I want is for it to snap back to its starting position when you stop holding the RMB down, can anyone help me with this?
function Update () {
if(Input.GetButtonDown("Fire2")){
transform.Translate (0.31,0.21,0);
}
}
Comment
Best Answer
Answer by Fabkins · Oct 29, 2011 at 10:01 PM
I would have thought testing against Input.GetButtonUp("Fire") with the opposite transform.
ie
function Update () {
if(Input.GetButtonDown("Fire2")){
transform.Translate (0.31,0.21,0); }
if(Input.GetButtonUp("Fire2")){
transform.Translate (-0.31,-0.21,0); }
}