How do i make a rigid body sphere, bounce of a rotating cube?

I am trying, to recreate an old game. Called “I’ve got some balls”.
But, whenever the player sphere, hits a rotating wall, i falls through it, or it just get’s stuck in it.
The wall is 0.4 thick. Do i have to make it thicker?
The wall rotation code:

if (turnAxis == 0)
	rotation = Quaternion.Euler(0, desiredAngle, 0);
else if (turnAxis == 1)
	rotation = Quaternion.Euler(desiredAngle, 0, 0);
else if (turnAxis == 2)
	rotation = Quaternion.Euler(0, 0, desiredAngle);
transform.rotation = rotation;

The ball is my own physics material, called Marple.

What colliders do the ball and wall have?

1 Answer

1

Try to use rigidbody.rotation instead of transform.rotation. Use it in FixedUpdate() instead of Update(), like this:

Quaternion rotation;
void Update () {
	if (turnAxis == 0)
		rotation = Quaternion.Euler(0, desiredAngle, 0);
	else if (turnAxis == 1)
		rotation = Quaternion.Euler(desiredAngle, 0, 0);
	else if (turnAxis == 2)
		rotation = Quaternion.Euler(0, 0, desiredAngle);
}
void FixedUpdate () {
	rigidbody.rotation = rotation;
}

Thank you, it works a bit better now. But the sphere. Still doesnt bounce off it.

How do you move the sphere? If you use a script to move it, then please show it.

Try to modify the velocity, like changing rigidbody.AddForce (cam.TransformDirection(Vector3.forward * fSpeed)); into rigidbody.velocity = cam.TransformDirection(Vector3.forward * fSpeed);

I got it working, without the velocity thing. Thanks for the help! :)

Please show how you fixed it, so other members can see the solution.