Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - princemoonrise

Pages: [1]
1
Okay, thanks for the tip, I think I got it to work; I used DOTweenPath instead of Tween when declaring, then the DORestart worked. Luckily it still let me keep my waypoint references with the Tween variable.  At first it didn't work but it was because I didn't have Relative checked in the path editor - but once I did that, no more popping when starting the tween.  Many many thanks!  :)

2
I'm having trouble getting DORestart to work... if I set it up like this:
Code: [Select]
myPathTween.DORestart(true);
with myPathTween being the name of the path tween I'm using, I get an error "does not contain a member "DORestart'..."

I noticed your example mentions myDOTweenAnimation... I don't have a DOTween animation(?) in my script or on my object.. only the path; are they two different things?  How can I implement the restart?  If I just do a restart, it still pops back to the waypoint position.  Currently the part of my code I'm trying to do the restart on looks like this, and does not work.  Please advise, thank you!!

Code: [Select]
void Start ()
{
tempPosition = gameObject.transform.position;
spawnedTime = Time.time;
myPathTween = this.GetComponent<DOTweenPath>().GetTween();
myPathTween.OnWaypointChange(WPCallback);
myPathTween.Play();
}

void Update ()
{
if (restartAfterSpawning == true && Time.time >= (spawnedTime + restartDelay)  &&  restartGate == true)
{
myPathTween.Pause();
restartGate = false;
gameObject.transform.position = tempPosition;
myPathTween.Restart();
myPathTween.timeScale = 1f;

}
}


3
Thank you for the advice and idea.  So does this mean I can make a path tween that starts slow or with little movement and when it gets to waypoint 1 I can immediately call a DORestart and have its path re-adapt to its current position?  My goal is to have enemies spawn in at different places, then have them use the same path relative to their position.  Would it work if I did that right when they spawned in?

4
DOTween & DOTween Pro / ID field in new version?
« on: April 24, 2016, 11:29:23 AM »
Hello again.. I was wondering what the new ID field is for in DOTween Path?  Will this allow us to have multiple Tweens with different ID's per gameobject? by having multiple components with different ID's?  (I recall seeing it said this wasn't possible before?)  If not, what is the field used for?  Thank you!  :)

Edit:  Saw the answer on the most recent thread... but I suppose I can use this to ask another question:

What happens if I give tweens the same ID?  Will calling Play cause all the tweens with that ID to play?

5
DOTween & DOTween Pro / Is DOTween Path relative movement possible?
« on: April 11, 2016, 12:58:12 AM »
Hello again.  I was wondering if it were possible to have a gameobject moving on a DOTween path move relative to its own position instead of world coordinates?  If my understanding is correct, is the "Relative" option in the Path Editor only applicable to editing the tween and does not apply to when the tween is actually used?

When I start a tween, the object always pops/teleports to waypoint 1's world coordinates when it begins.   Additionally, if a tween is in progress and something happens like a physics force to an object, it will pop back to the waypoint's world position which does not look good.  I've tried "Local Movement" but it does not seem to fix this.  For instance if I make waypoint 1 be (0, 40, 0), can I make the object just move to y 40 from wherever the gameobject is (treating the gameobject as (0, 0, 0), rather than teleport to (0, 40, 0) when the path is started?  If an object's position changes between one waypoint to the next, can it smooth it out and re-plot the next waypoint accordingly instead of popping?  I know I can probably just use DOMove for simple movement but Path patterns allow so much more.  I apologize if I may not understand very well how it works.

Perhaps a solution can be brute-forced by having the waypoint values offset based on the gameobject's position when the tween is started or when a waypoint is reached, but I have a feeling that there is a built-in or correct way to do this that I have not found.  Please advise.  Again, thank you very much for your tool.

6
Last question I asked wasn't stated clearly so I'll try again.

I cannot find any documentation on how to use OnWaypointChange in conjunction with the DOTween Pro Path / Visual editor.  Events such as OnComplete have have boxes in the inspector that can be used to trigger functions in scripts, but I don't see that sort of functionality for the waypoints.  I tried to use OnWaypointChange in a script but couldn't get it to do anything with the path waypoints in the editor/inspector (does it only work with ones that are specified in code?).

Can someone provide an example of how to use OnWaypointChange in a way that can reference the waypoints I am using in the DOTween Pro Path Visual Editor in a script?

I'm really stuck so some insight would be greatly appreciated, thanks.


7
I managed to use the copy to clipboard button in the editor to copy the values and put them into the script to satisfy the array, but all that does is send the gameobject warping through all the waypoints as soon as it is spawned.  I think more specifically the solution I need is one that allows me to receive the OnWaypointChange in a script, from the gameobject moving on the DOTween path I created in the pro/visual editor... and I have no idea how to do that.

Please help?  :(

More code I tried that didn't work:
Code: [Select]
Tween path = GetComponent<DOTweenPath>().GetTween();
path = transform.DOPath(waypoints, 1).OnWaypointChange(MyCallback);
path.Play();

8
Hello again.  I am trying to figure out the syntax for doing a callback when using OnWaypointChange.  Reading the documentation it looks like I need to supply "waypoints" which I know is a Vector3 array, but I want to use the values that are in the DOTween Path I've created in the pro editor.  I've tried to figure out how to do this for hours and the lack of examples has me stuck, and I'm not even sure if I'm close.  Please advise; here's my non working code:

Code: [Select]
private Vector3[] waypoints;

void Start ()
{
Tween path = GetComponent<DOTweenPath>().GetTween();
waypoints = path.PathGetDrawPoints;
transform.DOPath(waypoints, 1).OnWaypointChange(MyCallback);
}

For awhile it seemed I was getting closer, but I think it needed the array length and PathGetDrawPoints.Length wasn't working for it.

Ultimately I actually don't care about the waypoints array as long as I can run the path tween I made in the editor, and can do my callback when the waypoint change is made; if there is a more direct solution that would be fine too.

Would it be possible to add the waypoint callbacks to the Pro Editor/Inspector in the future, similar to how I can do them for OnComplete, OnPlay etc?

9
I have another question related to this, as I am expanding on where I can use the Flash Ease functionality.  Is there any way to define or force the start value of the ease/tween?  In my case I'm dealing with color, so my problem is that if I do want to have simultaneous flashes I don't want the Flash Ease to get its starting color from the wrong state.  I already have my desired start values stored as a color list when the game object is generated, but I need a way to tell DOTween to always go back to my stored color rather than the color it sees when it starts.  Though I'm guessing it may be possible with generic ways, I'm not experienced enough with lambdas or the generic coding way to figure out the syntax.

Would you have any suggestions on how I could use a predefined starting value for the Flash Ease?  Thank you!

10
Perfect solution, the restart does exactly what I needed it to so I can repeat the tween when another hit or activation occurs.  Here is the code I used after the fix:

Code: [Select]
if (isFlashing == false)
{
isFlashing = true;
myTween = rend.material.DOColor(Color.white, 0.2f).SetEase(Ease.InFlash, 2, 0).SetAutoKill(false).OnComplete(ResetFlash);
}

if (isFlashing == true)
{
myTween.Restart();
}

Thanks so much for the help! DOTween is the best!

BTW why is the forum hit with so much spam?  :(

11
Hello.  I have attempted to implement Flash SetEase for DOColor for a couple of different situations, but in both cases, problems occur if it is started again when it is already in progress.

In my first case, I attempted to make an enemy flash white briefly upon being hit, by changing the material renderer color.  If it is hit twice in a row, the object will permanently stay white and never go back to the original color.

In the second case, I tried to make an outline in the UI blink for a few moments when health is restored.  However if it happens while the flashing is already activated, the flash rate will appear to be on white twice as much, which is expected.  However after the flashing stops, the next time the flashing is activated it will retain the undesired double white period, and the problem can be repeated until it will only appear as solid white with no flashing.

The code used is below, it is fairly straightforward.

Code: [Select]
Case 1:
rend.material.DOColor(Color.white, 0.02f).SetEase(Ease.InFlash, 4, 0);

Case 2:
Color whiteopaque = new Color32(255,255,255,255);
Text.GetComponent<Outline>().DOColor(whiteopaque, 1.6f).SetEase(Ease.InFlash, 28, 0);


I thought of putting a bool there to prevent the flash from reactivating, that would reset after OnComplete, but I want a new activation to reset the flashing duration instead, so to do that I had to use a coroutine instead of the SetEase to get the functionality I want.

However, I was wondering if you have any suggestions or if DoTween has any built in functionality to prevent the double flashing / stuck white problem, or a way of adding to the timer that I am not aware of.  I would like to use DoTween if it is possible!  Thank you very much for any advice!

12
Thank you so much, the code worked perfectly!  I did try declaring the tween first but didn't think to try to play the tween as the last step.

DOTween is amazing, and I've already been able to use it for many purposes.  I have another problem I need answered but I will post a new topic to keep the forum organized.  Thank you again for the help and your amazing asset!

13
I am trying to do a callback from OnComplete, when using a DOTween Path.  While I was able to get it working by using the OnComplete tab from the inspector and placing the prefab in the object select box, I also wanted to be able to call it from code.

I was able to get the path to activate by using DOPlay, but it seems I cannot get the syntax right for the callback (I am very new to C#/Unity so please bear with me!);  could someone suggest the proper syntax for this?:
Code: [Select]
GetComponent<DOTweenPath>().DOPlay().OnComplete(MyCallback);
Thank you for your help!


Pages: [1]