- Home /
Sphere with Attach Transform?
Using a basketball as an example, when I grab it my hand is inside of the ball. The ball in this case is so large that my head is inside as well. Is there a transform (or anything) that will make the attach point the outside surface of the ball? I tried an attach transform but so far no luck.
I'm using an XR Ray Interactor to grab it if that makes a difference.
... I believe I will use a different approach. There is a lot to be said for maintaining the center point of the sphere when rotating the object.
Again it is an XR Ray Interactor so can I limit the "pull" distance? Not the distance the ray is cast but rather how close I can pull the object towards my hand. I will guess this needs to be coded so while I'm looking for it any hints as to which event I add this to?
Thanks again.
Answer by MarekRimal · Jun 01 at 09:31 AM
I am not exactly sure what have you tried but I guess when you grab the ball the hand snaps to the attach transform. When the attach transform is in the middle of the ball, then the hand snaps into the middle of the ball. If you put the attach transform on the surface of the ball then it will snaps to the surface. It would would have strange snap effect though because the attach point is on specific position (lets say the balls north pole). If you would like to remove this snap and be able to grab the ball in the exact point where your hand is then you can simply move the attach point to the hand position when the hand starts colliding with the ball.
Answer by tleylan · Jun 01 at 12:18 PM
I tried placing it on the surface but as you point out it creates an odd effect. Clearly games have people grabbing basketballs and such do you think they are moving the attach point?
I was wondering if there was a way to define something that didn't snap to the center of the ball that I was unaware of.
The hand is snapping to the attach point. So when you are about to grab the sphere, move the attach point to the hand position => No snapping. Solved.
I mean by a script. Probably use some OnGrabEnter and OnGrabExit or what is there. In enter set the attach to the hand position and on exit set it to the center of the ball for example.
As far as I can see if I move the origin of the sphere then it will never rotate "in place" around the center point but rather around the new center point which is outside the sphere.
I think there must be some standard solution I'm overlooking.
I think I am not much sure what are you trying to achieve. You want to grab a ball the same way as you would grab a basketball ball? That means you want to position your hand on the surface of the ball? Are you grabbing the ball from distance using some ray or directly using a hand? I mean normally in reality when you are holding a ball with your hand and rotating your hand the ball does not rotate around its origin but around the wrist you are holding it with... Its all about where to put the attach point.
If I understand correctly you want to grab a ball from a distance using a ray and you want to place your hand on the surface of the ball. Then set the attach transform to this position: Get a Vector3 dirToPlayerHand = (playerHand.position - ball.position).normalized()
and then set the attach point to ball.position + dirToPlayerHand * ballRadius
Answer by hirenmakwana · Jun 01 at 12:25 PM
try changing collider size
Um... because that will work or you are guessing? Isn't the center point of a larger collider still the center point of the sphere?