There is a box which, on mouse down should rise by 25 units. (I am able to do this by the transform.translate method)
But upon mouse click again, the box should go back and sit on its original position.
(I’ve spent an entire week going through forums/ tutorials, but in vain)
I dont know how to set variables (if this is what it requires)
There are a couple of ways to do what you’ve asked:
The most obvious would be to add a override function OnMouseUp() (see Unity scripting reference - OnMouseUp) and use the transform.Translate(-25) since you’ve only moved in a single direction.
You could, alternatively, record the starting transform (including position and rotation) and reset the values OnMouseUp.
If this script is attached to the game object in question then replace MyGO with “gameObject” and go from there (I don’t want to write your script for you, I’m trying to lead you to the well and make you drink on your own ). I hope your demo went well or got rescheduled…
It sounds to me like you’re just starting with scripting and so I really encourage you to work through the tutorials on our site and the community wiki before going too much further. That way you’ll develop a solid foundation first as we’re explaining what should be ultra-simple things for scripters to sort out. We all start somewhere so I’m not knocking you, I’m just saying that basic intro tutorials is where you ought to go next.
:lol:
Couldnt agree more.
I think I should stick to the art part of it and leave the scripting to the pros.
Got a friend to help me out with it.
Thanks for your attention.