hello. i am trying to get bonus items of my game tossed into the air relative to how fruits and bombs are flung/thrown in the game fruit ninja. i was trying to think of a way to do this by transforming the position of the game object up so that it enters the scene, and then changing the gravity scale on the rigidbody2D after some time so that it freefalls out of the scene. i tried doing this with this code -
var speed : float = 3.4;
function FixedUpdate () {
if (transform.position.x > 0) {
Moveleft();
}
else {Moveright();}
}
function Moveleft () {
transform.position.y += speed * Time.deltaTime;
transform.position.x -= speed * Time.deltaTime;
}
function Moveright (){
transform.position.y += speed * Time.deltaTime;
transform.position.x += speed * Time.deltaTime;
}
but the items spawn at random x coordinates and then fall directly along the 0 x coordinate. i think i am doing this wrongly and henceforth i am seeking professional assistance. the effect i am seeking is the randomized flinging of the bonus gameobject into the scene relative to the way fruit is flung into the air in fruit ninja. any help with this will be greatly appreciated. this is being done in 2d with javascript. thanks in advance.