Two DOJumps in a sequence
« on: August 13, 2015, 11:48:20 AM »
Hi, I need an object to jump twice in a row: the first jump should end at "position1", and from there, the object should jump to "position2"

Here's my code:

Code: [Select]
void Start() {
transform.position = Vector3.zero;
// transform.position = Vector3.up; - doesn't work

var position1 = new Vector3 (5, 0, 0);
var position2 = new Vector3 (10, 0, 0);

transform.DOJump (position1, jumpPower: 5f, numJumps: 1, duration: 1f)
.Append (transform.DOJump (position2, jumpPower: 5f, numJumps: 1, duration: 1f));
}

This only works fine when the starting point is at the same height as the target - but if the object starts at (0,1,0), it ends up at (10,-1,0) instead of (10,0,0).

Am I doing something wrong? How do I go about chaining jumps properly?

Re: Two DOJumps in a sequence
« Reply #1 on: August 13, 2015, 02:19:47 PM »
Ok, nevermind, I ended up writing my own tween instead of using DOJump.

Anyway, I had a look at the source code and I think there are several issues with the DOJump method:

First of all, you should be setting offsetYSet to true in OnUpdate(). And you should probably move " float startPosY = target.position.y;" into OnUpdate(), so that the offset gets computed from the current position of the object instead of the object's position at the time of the DOJump() call - maybe that would solve the issue with chaining jumps with different endValue.y's?

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Two DOJumps in a sequence
« Reply #2 on: August 14, 2015, 12:20:29 PM »
Hi,

You're right, the DOJump shortcut is not made to be chained in Sequences, my bad. Adding it to my todo list.

Cheers,
Daniele