Object move like ballon

hi can any one suggest i want my game-object floating up just like balloon move right to left or vice versa.

The are multiple ways of solving this problem.

  • Create an Animation
  • Use iTween, create a path, and use iTween calls for rotation
  • Use physics (2D or 3D)
  • Write a script

And there are multiple issues depending on camera angles and/or if this is a 2D or 3D app.

Here is a bit of starter code that works if the camera and the object have near zero rotation (0,0,0).  It would work well for a 2D app for example.

#pragma strict

var rotateAmount = 15;
var rotateSpeed = 2;
var wind : Vector3 = Vector3(0.5, 0, 0);
var riseSpeed = 1.0;

var angle = 0.0;

private var vMove : Vector3;

function Start () {
    vMove = wind + Vector3(0.0, riseSpeed, 0.0);
}

function Update () {
    angle = Mathf.Sin(Time.time * rotateSpeed) * rotateAmount;
    transform.eulerAngles = Vector3(0.0, 0.0, angle);
    transform.position += vMove * Time.deltaTime;

}