i’m making a catapult kind of thing and on the swinging arm part, i have a box collider, and a script to rotate it
void FixedUpdate ()
{
if (rotating) {
Vector3 r = new Vector3 (-2.5f, 0, 0);
rotatingArm.Rotate(r);
Debug.Log ("CatapultController rotatingArm.eulerAngles.x = " + rotatingArm.eulerAngles.x);
if (rotatingArm.eulerAngles.x < 300)
rotating = false;
}
}
i also have a ball, it has a sphere collider and rigidbody.
if i make the rotating arm with no rigidbody, then i drop the ball onto the arm, the ball sits there on the collider ok until i start rotation. when i set rotating=true the arm rotates, but it passes through the ball like its made of gas.
so i add a rigidbody, and turn ‘Is Kinemic’ on to stop the arm falling through the floor. now i drop the ball on the arm ok, then when i rotate, the ball moves correctly with the rotation of the collider. BUT, at the end of the rotation, when x<300, i stop the rotation, the ball stops. shouldn’t it go flying off the direction it was moving when it stopped?
thanks
BTW, i fixed the problem, kind of, by adding this
Rigidbody rb = objectInBasket.GetComponent ();
rb.AddForce(new Vector3(100,0,40));
in the if(x<300) case, but it seems to me like that shouldn’t be necessary?