Moving on the local z using DOTween.

Hi,

I am having an issue with using DoLocalMoveZ to move forward. I have a character that I rotate then move forward on the transforms local z axis but it is using world z when I move. Basically it always moves up 3 on the world z axis but I need it to move up 3 on the transform’s z axis.

Here is an example of what I have…

//swipeUp

transform.parent.DORotate (new Vector3(0,0,0), 1f);

Move();

//swipeDown

transform.parent.DORotate (new Vector3(0,180,0), 1f);

Move();

private void Move()

{
transform.parent.DOLocalMoveZ(transform.parent.position.z + 3, 1f);
}

Thanks in advance!

Ok
i solved it
instead of using DOLocalMoveZ i used
transform.DOMove(transform.position+transform.forward, 1f );

This is an old question but let me write an updated reply here:

Now local coordinates related movement supported in DoTween, here you have one example for this:

slidingStair.DOLocalMoveY(0f, 2f);

This way you have all other animations methods exist to do something on a local basis.

The answer by @anuj is correct. If you want to move forward by a certain amount you’d multiply transform.forward.

float offset = 2.34f; //how much to move forward
transform.DOMove(transform.position+transform.forward*offset, 1f );

Hi, did you ever figure this out?