Question by
tiwariavinash503 · Apr 09, 2018 at 08:36 PM ·
freezethrowinganimated-models
The best way of making an animated hand throw a rigid ball? and why the ball suddenly freezes although the gravity works?
hey, I'm an absolute beginner and I'm stuck at a point. I am making a game which has an animated hand model which throws a rigid ball for which I'm using animation event to addforce .
``I founded only one helpful tutorial on youtube and I just copied what he did but in my project, the ball suddenly freezes after a jerk. Can anyone please help? I'm on a very tight deadline. first, a script is attached to the model to be called in animation event, below is the script
#pragma strict
var theball:GameObject;
function Start () {
}
function Update () {
}
function ThrowBall (){
Debug.Log("Throwing!");
var ballscript:Ballscript=theball.GetComponent("Ballscript");
ballscript.ReleaseMe();
}
now the script attached to the ball
#pragma strict
var parentbone:GameObject;
var rigid:Rigidbody;
var lastPos:Vector3;
var curVel:Vector3;
function Start () {
transform.parent=parentbone.transform;
rigid.useGravity=false;
}
function Update () {
}
function ReleaseMe(){
transform.parent=null;
rigid.useGravity=true;
transform.rotation=parentbone.transform.rotation;
rigid.AddForce(transform.forward*2000);
}
please, can anyone solve the problem, I shall be highly thankful.
Comment