using UnityEngine;
using System.Collections;

public class BananaTc : MonoBehaviour
{
	public float BananaForceUp		= 1000;

	void Start ()
	{
		Init();
		rigidbody.AddForce( Vector3.up * BananaForceUp );
	}
	
	void Update ()
	{
		transform.Rotate( Vector3.back * ( transform.localRotation.z + Time.deltaTime * 1000 ) );

		if ( !renderer.isVisible )
		{
			DestroyObject( gameObject );
		}
	}

	void Init()
	{
		GameObject Monkey = GameObject.Find( "Player" );

		if ( null != Monkey )
		{
			transform.position = new Vector3( Monkey.transform.position.x + 0.25f, Monkey.transform.position.y + 1, Monkey.transform.position.z - 1);
			rigidbody.velocity = new Vector3( Monkey.rigidbody.velocity.x, Monkey.rigidbody.velocity.y, Monkey.rigidbody.velocity.z );

			Debug.Log( "Banana created on: " + transform.position.ToString() );
		}
	}
}
