- Home /
Question by
jamison 1 · Dec 16, 2010 at 01:07 AM ·
movescript-ready-to-use
simply move an an object
Can someone give me a script that lets me move a simple cube up and down just to see if the camera works in 2d motion?
Comment
Answer by ina · Dec 16, 2010 at 01:10 AM
Create a new script below, and drop it in your cube. Press play and the cube will move up and down using the awsd or up and down arrow keys (unless you changed the ide's default keyset)
function Update () { transform.Translate(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"),0); }
For further explanations, you might want to look @ http://docwiki.unity3d.com/uploads/Main/Scripting%20Tutorial.pdf
You probably want to include Time.deltaTime as well. I know it's just a code example, but unfortunately some people here don't know that. And good choice of link. :)