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!
Answer by anuj · May 13, 2018 at 10:16 AM
Ok i solved it instead of using DOLocalMoveZ i used transform.DOMove(transform.position+transform.forward, 1f );
Answer by chris3000sa · Jun 01, 2018 at 11:44 PM
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 );
Answer by siddharth3322 · Jun 05, 2019 at 10:13 AM
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.
Your answer
Follow this Question
Related Questions
Buy Unity Assets 0 Answers
I cannot access my purchased Asset Bundles in Unity! 0 Answers
What is happening? 0 Answers
uNet with ootii motioncontroller 2 Answers
"Fungus" asset Error CS0121: The call is ambiguous between the following methods or properties... 0 Answers