add constant z axis movement to third person / character controller

is there any way I can add a continuous forward movement to a third person character? The game is a snowboard game so I only want it to move / rotate left and right. I have tried using a ridged body instead but am having uber problems getting it to work how I want

Thanks!! :)

Have you taken a look at ConstantForce? http://unity3d.com/support/documentation/ScriptReference/ConstantForce.html . It provides relative and absolute force (and torque) and remains in effect until you apply a different force to the rigidbody.

You can try with a simple animation-driven character controller like the one released for Unity by Mixamo. It is powered by a RootMotionComputer script, created by Adam Mechtley. It allows the controller to use actual animation curves to drive the motion of the root of the character, instead of using a procedural approach which would lead in general to a worse quality and motion artifacts like foot slide. On top of that you can add a constant Z-foward speed on the parent game object on the Update() function. Done. Hope this helps!

You can download the project file, as well as see video tutorials about its use here:

http://www.mixamo.com/c/unity

Cheers!

Stefano

i think you can use wheel colliders for this. if you want to constantly move something you should call Transform.Translate or CharacterController.Move in Update.

Here's something I had tried out sometime back for something similar..

public float movingRate = 0.1f; //rate of movement
private float mLeftRightInput; //Left-Right input
private bool mDoLeftRightMove = false; //is moving Left or Right
private bool mDoStartMoving = false; //has simulation started
private Vector3 mDelta; // the movement delta every fixed update

In your Update() function check for left-right input.. (am assuming you are checking for Left-Right arrow keys only for now.. hence only checking the "Horizontal" axis)

void Update()
{
    mLeftRightInput = Input.GetAxisRaw("Horizontal");
    if (mLeftRightInput != 0)
       moveLR = true; 
}

Then in your FixedUpdate(), make the character move accordingly..

void FixedUpdate()
{
    if (mDoStartMoving)//if simulation has started..
    {
        if (mDoLeftRightMove)
        {
            mDelta = transform.right * movingRate * mLeftRightInput;
            mDoLeftRightMove = false;
            rigidbody.MovePosition(rigidbody.position + mDelta);
            EaseRotation(Quaternion.LookRotation(mDelta)); // this is simply Lerping the rotation in the direction of mDelta
        }
        else
        {
            mDelta = transform.forward * movingRate; //this will keep it moving in the forward direction
            rigidbody.MovePosition(rigidbody.position + mDelta);
            EaseRotation(Quaternion.LookRotation(mDelta)); // this is simply Lerping the rotation in the direction of mDelta
        }
    }
}

This still uses a rigidbody, but that's just because my thing was a physics simulation.. and its just easy that way! Hope this helps!

Restrict vertical

pragma strict
function Update () { var zMove : float = Input.GetAxis(“Vertical”) * Time.deltaTime * 2; transform.Translate(Vector3(0,0,zMove)); transform.position.z = Mathf.Clamp(transform.position.z, 25, 550); }

Restrict Horizontal

pragma strict
function Update () { var xMove : float = Input.GetAxis(“Horizontal”) * Time.deltaTime * 2; transform.Translate(Vector3(xMove,0,0)); transform.position.x = Mathf.Clamp(transform.position.x, 25, 550); }

In Mathf.Clamp(transform.position.x, 25, 550); set your coordinate boundry