Some tweening help needed.
« on: August 10, 2015, 07:52:28 PM »
I use moving from place "start" to place "end" this kind:
transform.DOMove(end, 1); .. and it is ok.

1 st question:

Now I need tween that moves transform half way to "end" and then back to "start" (in 1 sec) (I use it as attack movement in tile based game)
How I do it DOTween?

2 st question:

I need tween cannonball as "bow" from "start" to "end" this: transform.DOMove(end, 1); do straight line. (Something that birds fly in Angry Birds or cannon ball in tank games)
How to do it in DOTween?

3 rd question:

I need tween boolean value that is set to true.. but is set to false after 2.5 sec.. How to doit wit DOTween?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Some tweening help needed.
« Reply #1 on: August 10, 2015, 08:23:29 PM »
Hi,


1st question
You should create another tween in that case


2nd question
You can apply a DOJump tween, to choose the height of the jump and thus create an arc


3rd question
Check out DOVirtual.DelayedCall

Re: Some tweening help needed.
« Reply #2 on: August 10, 2015, 10:53:28 PM »
Hmm how to make call back with parameter?

I get this work:

void DoAct()
{
 DOVirtual.DelayedCall(attackMoveSpeed, moveBack, false);
}

void moveBack()
{
        transform.DOMove(attackStartLocation, attackMoveSpeed);
}

I would like to do (But I bet compile error)

void DoAct(vector3 location)
{
 DOVirtual.DelayedCall(attackMoveSpeed, moveBack(location), false);
}

void moveBack(vector3 location)
{
        transform.DOMove(location, attackMoveSpeed);
}

also how to make call "inline" for example if I want just change boolean and does not want to do own method for it?
Something like:  DOVirtual.DelayedCall(2.5f, isBusy = false, false);
« Last Edit: August 10, 2015, 11:47:20 PM by DJVDJV »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Some tweening help needed.
« Reply #3 on: August 11, 2015, 09:42:52 PM »
Instead of this:
Code: [Select]
DOVirtual.DelayedCall(attackMoveSpeed, moveBack(location), false);you should pass just the function name:
Code: [Select]
DOVirtual.DelayedCall(attackMoveSpeed, moveBack, false);
And to make it inline you can use a lambda instead:
Code: [Select]
DOVirtual.DelayedCall(attackMoveSpeed, ()=> isBusy = false, false);

Re: Some tweening help needed.
« Reply #4 on: August 12, 2015, 09:11:17 AM »
This one:
"
DOVirtual.DelayedCall(attackMoveSpeed, moveBack(location), false);
you should pass just the function name:
DOVirtual.DelayedCall(attackMoveSpeed, moveBack, false);
"

But how to pass location as parameter?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Some tweening help needed.
« Reply #5 on: August 12, 2015, 01:15:21 PM »
Sorry I should've specified that. DelayedCall doesn't accept parameters, so you can only call methods that have no parameters. Or use another type of lambda like this:

Code: [Select]
DOVirtual.DelayedCall(attackMoveSpeed, ()=> moveBack(location), false);

Re: Some tweening help needed.
« Reply #6 on: August 12, 2015, 02:29:41 PM »
Now it works. Thanks LOT!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Some tweening help needed.
« Reply #7 on: August 12, 2015, 03:29:02 PM »
Great :)