- Home /
how to drag gameobject up to 180 and down to -180 using mouse drag?
void Update () {
if(Input.GetMouseButton(0))
{
Vector3 mousePosition = Input.mousePosition;
if(transform.localPosition.y >= 180) {
// print ("up");
return;
}
transform.Translate(0,2 * Time.deltaTime, 0 ) ;
print ("down");
if(transform.localPosition.y <= -180) {
return;
}
transform.Translate(0,-2 * Time.deltaTime, 0 ) ;
}
}
Can you explain your question with a bit more of detail. I'm having a hard time even understanding what you are trying to accomplish.
i have a wall of component cube in my scene and i want to it up and down using mouse how could it would be possible. I am new to unity that's why i don not which approach should i use.?? And i want to move wall upward to 180 and downward to -180. thanks
That's not an explanation. what kind of behaviour do you need? Do you want to drag the object with mouse, or do you want the cube move by mouse click, moving with time or instantly?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# destroy gameobject with tag 5 Answers
How to make a drag/drop script only affect objects with a tag? 1 Answer
Flip over an object (smooth transition) 3 Answers