Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: r_chevallier on December 03, 2015, 07:37:10 AM

Title: transform.forward equivalent?
Post by: r_chevallier on December 03, 2015, 07:37:10 AM
Hello,

I have a rocket prefab that spawns in different directions throughout the game so I can't just have 1 transform move direction.

Is their an equivalent to "transform.forward". Your asset is much easier to move objects than Unity's native code.

I have gotten the below Unity code to work but want to use your asset for better control.
transform.Translate(Vector3.right * Time.deltaTime * speed,Space.Self);

Thanks,
Raymond
Title: Re: transform.forward equivalent?
Post by: Daniele on December 03, 2015, 05:12:27 PM
Hi,

You can simply use Transform.forward and multiply it for the distance you want to achieve, then use SetRelative. For example, this will send your rocket forward for 5 units in 2 seconds, depending on its rotation.
Code: [Select]
transform.DOMove(transform.forward * 5, 2).SetRelative();
Title: Re: transform.forward equivalent?
Post by: Neogene on March 01, 2016, 12:12:12 PM
Hi

why not add to the API a method like SetUseAxis(def = true) which allows to use the forward/right/up axis e.g.: 

Instead of

transform.parent.DOLocalMove( transform.parent.up*moveDistance,duration).SetRelative(true)

use something like

transform.parent.DOLocalMoveX/Y/Z(moveDistance,moveDuration*moveSpeed).SetRelative(true).SetUseAxis();

which under the hood will do (transform.parent.right/up/forward)*moveDistance

and which will move along the Local Axis (forward/right/up).

have a nice day.
Title: Re: transform.forward equivalent?
Post by: Daniele on March 02, 2016, 12:06:06 PM
Hi,

This is interesting. Adding it to my todo list and will see if it's doable :)

Cheers,
Daniele
Title: Re: transform.forward equivalent?
Post by: Neogene on March 02, 2016, 12:11:18 PM
Buon divertimento  ;D

Hi,

This is interesting. Adding it to my todo list and will see if it's doable :)

Cheers,
Daniele
Title: Re: transform.forward equivalent?
Post by: Daniele on March 02, 2016, 12:16:17 PM
Ahaha grazie :D