Ridiculously easy question: Moving an object

I'm having trouble moving a basic rigid body object. Simple I know. But I just can't seem to get it to work. All I want to do is move it by a basic 3D vector. Does anyone have any tips how I can do it? I'm rather new to unity.

function Update () {
    var acceleration = iPhoneInput.acceleration;
    var offset : Vector3 = Vector3(acceleration.y,acceleration.x,0);
    rigidbody.MovePosition(rigidbody.position + offset);

You can use

rigidbody.MovePosition(rigidbody.position + offset);

Where offset is the vector direction you want to move in

Check out iTween, its an epic animation script for unity, beats the hell out of the default unity animator. there is documentation and video tutorials on the site:


hope this helps

There are multiple ways to move objects. Through rigidbody force (the physics system, through Linear Interpolation (Lerp for short), and also through the transform (which I believe uses Matrices Transforming, but I'm not a math guru).

I've written a detailed guide on how to move through rigidbody forces on my studio's website http://wiki.certainlogicstudios.com/

There is also the CharacterController class, which uses one of the above listed methods. I'm not sure which one. The class itself has something of a bad reputation. I think it is expensive to use, and is only meant to be used on 1 character in your game at a time, like the main player in a platformer (but not the enemies).

iTween does take a lot of the mystery out of movement (unless you wonder how they are performing their black magic, then it's even more mysterious!). I don't have a lot of experience with it, so someone please correct me if I am wrong, but I don't believe you can use the physics system with it.

So, it really depends on the kind of game you are making, and how you want your objects to react.

Edit: Make sure you do your physics updates inside of FixedUpdate, which fires at a constant interval. Update fires once per frame, and is therefore dependent on the frames per second of the computer running the game. You may experience poor physics simulations because of that.

Nowadays i HIGHLY recommend navmeshagent’s. It’s by a long shot the easiest way you can do things unless you are making an RTS where tons of units go to one point because then avoidance becomes an issue otherwise just set the stopping distance value.

just do:
NavMeshAgent agent;

agent = getcomponent(NavMeshAgent);

and then agent.setdestination(vector3);
bake a navmesh on your level you can go up hill and all no problems with good collision already built in.