Firing projectile in curve

Okay so I am having some trouble with this.
I have an object in unity called Catapult arm. This object contains the meshs and colliders for the arm of a catapult which can be controlled using the arrow keys. The catapult arm object also contains a test block that I am trying to launch when the catapult arm reaches a certain angle (normally reached when firing).

By default the projectile block has a rigidbody set to not use gravity and to be kinematic, this is so that it plays nicely when moving the catapult arm object with the arrow keys. This is all fine and I can raise and lower the catapult arm and block.

The problem comes with when the firing angle has been reached. I have a script attached to the projectile called “changeProjectileState”. this script is as follows:

gameObject.tag == "projectile";
function Update () 
{
	if(rigidbody.isKinematic == true)
	{		
		if( transform.rotation.eulerAngles.x >= 75
			&& transform.rotation.eulerAngles.x <= 85)
			{
			transform.parent = null;
			rigidbody.useGravity = true;
			rigidbody.isKinematic = false;
			}
	}
}

I then have a script attached to take care of the movement of the projectile when it is no longer attached to the arm object.

This is the problem as currently it just adds a force to the object and doesnt stop. I want it to take advantage of the activated gravity and apply a single initial force and then leave the rest to the engine so that the block slows down and stops.

gameObject.tag = "projectile";

function Update () 
{
if(rigidbody.isKinematic ==false)
{
if(rigidbody.AddForce.z <= 20)
{
    rigidbody.AddForce (0,0,10);
}
}
}

Any help would be really appreciated. :slight_smile:

How about this-

function Release()
{
    yield WaitForFixedUpdate();
    var curPos : Vector3 = transform.position;
    yield WaitForFixedUpdate();
    var deltaPos : Vector3 = transform.position - curPos;
    var calculatedVelocity = deltaPos / Time.fixedDeltaTime;
    transform.parent = null;
    rigidbody.useGravity = true;
    rigidbody.isKinematic = false;

    // this is the key bit-
    rigidbody.velocity = calculatedVelocity;
}

This samples the movement of the arm at the moment just before the ball should be released, and sets its velocity accordingly.