- Home /
Rigidbodies misbehaving when another is rotated
I have a scene with some simple physics stuff. There's a big ball on a long ramp, as well as a pedestal-mounted launcher nearby that shoots small balls based on its current orientation.
125125
This setup normally works fine, but when I made the launcher's azimuth adjustable by keyboard, weird things began happening.
If the launcher is aimed forward and tilted up (45 degrees in elevation, 0 otherwise), the scene performs fine. The big ball rolls down the long ramp in the background, and the launcher fires small balls on demand, which bounce along in a reasonable path. However, as soon as the launcher is rotated (slewed) to an azimuth of about -60 degrees, the big ball suddenly SHOOTS sideways/backwards off the ramp. It then hits an invisible wall in midair, causing it to fall almost straight down, then it lands and rolls forward and sideways. There is nothing there for the ball to hit in midair, and there are no surface features on the ramp, so this is quite perplexing.
Also, the small balls from the launcher will now (seemingly at random) fire out at an incorrect angle... the launcher will be aimed a bit left and they'll fly to the right instead, as if there's a wind blowing. As soon as the angle is tweaked or even the camera is moved, the next balls resume proper trajectory.
What on earth could be causing these anomalies? As far as I know, I have not tied the big ball to the launcher in any way, and the launched balls' trajectories should always be in the direction of the launcher. Perhaps there's some inherent flaw in the physics engine? "I just don't know what went wrong."
Info: The big ball and ramp are standard primitive rigidbodies with colliders (sphere and box respectively). Also, the scene uses a smaller physics time step, smaller penalty distance, and larger angular velocity limit than default because the balls won't collide/roll properly otherwise. Here is the relevant code for the launcher (attached to the nozzle piece that actually aims):
if(launchNow){
launchNow = false;
// FIYAH!
var newBall = Instantiate(projectile, transform.position + spawnDistance * transform.forward, transform.rotation);
var rb = newBall.GetComponentInChildren(Rigidbody);
rb.AddForce(transform.forward * force);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613072234im_/https://answers.unity.com/themes/thub/images/avi.jpg)