- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
CrilleStyles · May 19, 2014 at 01:48 PM ·
move an objectclick to movemove speedgun position
Move to a position on buttonhold?
How Do I move an object from a position and Keep it there when I'm holding down Rightmousebutton and then reseting it's position when the key is not pressed?
Comment
Best Answer
Answer by HarshadK · May 19, 2014 at 01:58 PM
You can get right mouse button using Input.GetMouseButtonDown and Input.GetMouseButtonUp where in you use index '1' to get the right mouse button input.
The psuedo-code for this will be like:
if(Input.GetMouseButtonDown(1)) {
// Move your object to expected position
Transform.position = expected position
}
if(Input.GetMouseButtonUp(1)) {
if(Transform.position == expected position) {
// Move your object to its original position
Transform.position = original position
}
}