DOJump Issues - Jumping to a Higher Platform
« on: May 19, 2015, 02:58:36 PM »
I posted this question on Unity Q&A before realizing there was a forum here.

I was using AddForce for my character's jumps, but someone recommended I use DOTween instead. I can get DOJump to work pretty well when two platforms are on the same y axis, but what I want is for my character to jump from a lower platform to a higher platform.

I tried making a Vector3 (nextPlatform) with the x value of the character when it's on the platform, a y value higher than the platform, and a z value of zero (since it's 2D):

       transform.DOJump(nextPlatform, 1, 0.3F, false);

The character doesn't land on the platform when the platform is raised, but when I move the same platform down, it lands just fine. How can I get the character to jump up to a higher platform?

(On a side note, I wasn't sure if I should use .SetEase possibly as well.)


*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #1 on: May 19, 2015, 07:55:22 PM »
Hi,


Indeed DOJump doesn't allow to change the final Y value, other than for the jump itself. I'm going to see if I can change this right now. Will be back in a short while.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #2 on: May 19, 2015, 08:40:04 PM »
Hey, get the attached version. Now the transform's DOJump shortcut (only that one, I will implement the others in the next days) actually takes the endValue fully, Y included, and adds a "jumpPower" parameter instead.

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #3 on: May 20, 2015, 10:19:48 AM »
Awesome. Thanks! I have it jumping to a higher platform. The only issue now is that when I increase the jump time, the jump becomes really choppy. I either get a jump that is too fast or a jump that doesn't work properly.


Thanks for responding so quickly and helping me out with this!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #4 on: May 20, 2015, 10:28:55 AM »
I just checked it out and it works perfectly here even with a very long jump duration. I have a feeling it might be because you're probably tweening a rigidbody, am I right? I'm gonna implement correct rigidbody DOJump shortcuts now, which will work much better than using a transform.

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #5 on: May 20, 2015, 10:31:00 AM »
You're correct - I am using a rigidbody. Thanks again! Looking forward to seeing how it turns out.

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #6 on: May 20, 2015, 11:02:00 AM »
Also, I'm not entirely sure what happened or if I did something wrong, but when I imported the attachment, I am no longer able to use DOFade on my text.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #7 on: May 20, 2015, 11:04:08 AM »
Here you go, see the new version attached. Now use

Code: [Select]
myRigidbody.DOJumpinstead of
Code: [Select]
myTransform.DOJump
which will internally use rigidbody's MovePosition rather than changing the transform's position directly, which is how it should be done :)

About the attachment, probably you didn't run DOTween's Setup again (it needs to be run each time you update, from Tools > DOTween Utility Panel), which is necessary to activate all additional shortcuts (like the ones for texts).

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #8 on: May 20, 2015, 11:46:08 AM »
Awesome. Thank you so much! It's looking really nice now.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #9 on: May 20, 2015, 11:55:56 AM »
Great :)

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #10 on: June 11, 2015, 10:59:28 AM »
Hello,

I downloaded the updated files for DOJump to jump to different Y heights. Here is my test code I applied to a cube:

transform.DOJump(new Vector3(1,1,0),2, 1, 0.5f, false).SetRelative();

The problem I am having is "SetRelative" is not working. The object still jumps to the Global position.

What am I doing wrong?

Thanks for your help.

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #11 on: June 11, 2015, 02:51:29 PM »
Hello,

DOJump returns a Sequence, not a Tweener, and SetRelative doesn't work with Sequences. I just realized though that it would be nice if it worked, especially for stuff like DOJump, so I'm gonna implement that. Should be done for tomorrow.

Cheers,
Daniele

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #12 on: June 11, 2015, 10:12:32 PM »
Voilą, update attached :)

Also, now SetRelative works with Sequences too (it sets all sequenced tweens as relative), plus I fixed a bug where a DOJump didn't end correctly in some cases, when using a single loop.

Re: DOJump Issues - Jumping to a Higher Platform
« Reply #13 on: June 12, 2015, 11:21:03 AM »
Thanks,

It works great. I have another question. I just noticed that there is a DOLocalJump in the transform Documentation. Is this the same as useing the "setRelative" for DOJump that you just added.

I will be sure to give you outstanding reviews on the ASSET STORE. :)

________________________________________________________________

New Question:
I have purchased another asset from the asset store and I am changing out some of there Player code with DOTween.

They have a line of code for movement if the up arrow is pressed(below):
     targetPosition = thisTransform.position + new Vector3(1, 1, 0);

I added your DOJump code(below):
     thisTransform.DOJump(new Vector3(1,1,0),2, 1, 0.5f, false).SetRelative();

Is there a way I can define the "targetPosition" to = the new DOJump code. Such as (this does not work but explains what I am trying to do):
     targetPosition = thisTransform.DOJump(new Vector3(1,1,0),2, 1, 0.5f, false).SetRelative();


Thanks in advance.


*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: DOJump Issues - Jumping to a Higher Platform
« Reply #14 on: June 12, 2015, 11:35:43 AM »
Great, and thanks :)

And no, DOLocalJump is not the same as SetRelative (they can actually work together). Instead, it simply tweens the localPosition instead than the position of an objects.

About the new question, I'm not sure of the functionality. I assume "targetPosition" sets the end position to reach, and then the asset animates towards that position during Update calls? If so, you could comment out the part where the targetPosition is used by the transform, and directly use a DOJump with the transform itself (otherwise no, you can't DOJump a Vector3 directly, because DOJump requires a transform/rigidbody target).


Cheers