Throwing a ball around

Hi all, Here’s my problem :

I’m using the FPS Character controller and i’ve attached an empty object called BallHolder (héhéhé i know!) and the ball is the children of it. When I click the mouse the ball object is released and should be throw.

Here’s my code :

var ballModel:Transform;
var parentModel:Transform;
var ballInPlay:boolean = false;
var ballPower:float = 2000.0;

function Update () 
{
	controlBall();
}

function controlBall():void
{
	if(Input.GetMouseButtonDown(0))
	{
		if(!ballInPlay)
		{
			ballModel.rigidbody.isKinematic = false;
			ballModel.rigidbody.AddForce(parentModel.Vector3.foward * ballPower);
			parentModel.DetachChildren();
		}
		
	}
}

My main problem is with the AddForce sentence. If I just put a Vector3 in there it’s works but since the player is rotating around, the ball goes only in the direction specified by the Vector3. But if I add the foward Vector3 I got this message from Unity :

MissingMethodException: Method not found: ‘UnityEngine.Transform.Vector3’.
NullReferenceException: Object reference not set to an instance of an object

Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type cacheKeyTypes,)

I don’t understand! Everything is nice in the editor, the transform are nicely put there.

Hey , first off im no professional … but try this
u just misspelled foward … its forward . Still if that doesnt work try (parentModel.transform.forward * ballPower)
and also you need to first detacch children and then apply force… cos if not the force will apply to the child and wont work, first dechild then apply force :slight_smile: hope it works

Well first that’s rigth freaking misspelled!!! Urgh! But also I didn’t unparent the model!

Well Thanks Masterdam!
:slight_smile: