Demigiant Forum
Unity Assets => DOTween & DOTween Pro => Topic started by: Radis 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:
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?
-
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?
-
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