jeango
1
Hi all,
I’m new to iTween but I would really like to create a sine motion for an object.
It’s for a shoot’em’up game, and I want my projectiles to move up and down on the y axis and to keep moving forward along the x axis.
I don’t want to use paths, because they are restricted to 10 nodes and as far as I can tell, there is no way to move an object relative to a path (they always start at the position of the start node of the path, which is not what I want). So I’m trying to set up tweens.
I’ve tried to add two “MoveBy” tweens, one with a pingpong loop along the y axis, and one with no loop along the x axis. However it seems you can’t combine tweens of the same type.
Is there a way to achieve this in iTween at all, or do I have to code all this manually?
I don’t want to use paths, because
they are restricted to 10 nodes and as
far as I can tell
This is not true. As far as I know, the only limitation on paths length is available memory.
But if you did not want to use a path, then write a simple script that moves your object up and down in a sine motion using local coordiantes. Then make your visible object a child of an empty game object. The empty game object is what you use with iTween.
Here is a simple script that moves an object up and down on the its local position in a sine movement:
#pragma strict
var max = 2.0;
var speed = 2.0;
function Update () {
var f = Mathf.Sin(Time.time * speed) * max;
transform.localPosition = Vector3(0.0, f, 0.0);
}