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.