- Home /
How to rotate an object 360 degrees around a sphere with collisions?
I am trying to make the movement of the checker (shown in a circle) equal to its diameter, the move is made only in the free space. (In the game, you can direct where the checker goes) To represent such a movement, we decided to make a outline circle, as a mark that the checker can go there. As an element of game design and simplicity, the outline circle can collide with other objects, preventing it from going into a closed position.
Here's a gameplay video showing how this should work.
To implement this, I made the following checker hierarchy:
Checkers brain -> Outline circle
The checker's brain is responsible for the player's turns and the move itself. To embody the turns, we change the transform.rotation, and the move is made to the position of the outline circle.
The outline circle is responsible for collisions with other objects, and does not allow you to go to a closed position.
And to make collisions with other objects, we decided to use the Physics.sphereCast.
The decision to use Physics.Spherecast as a bad decision, that's why:
Consider a situation where, in fact, the checker must pass through these walls. But he cannot pass through this wall, since the Physics.SphereCast works like a ray, the ray colliding with the wall tells the outline circle not to pass through the wall.
Can u find a solution for a outline circle that can collide with objects, but which does not work as a ray?
P.S. I tried to change the original position of Physics.SphereCast, but this does not work due to the fact that Physics.SphereCast only shifts towards the origin.