I should have made this one a while ago, the Interaction system that I’ve been making and teaching tutorials on makes heavy use of GrabPoint, but I never really explained how to set it up. So let’s do that.
For this one, we are going to be rigging this premade gun asset, (You might have noticed that I’ve been using this one for a while) we aren’t going to be making it shoot or anything, just grabbing. (Want me to go farther? Comment below!)
Once you have that, or your own model we can start rigging. Just to be clear I’m using my own Interaction Scripts, you can follow the tutorials or check out the GitHub. Now, we import it into our scene and first off disable the bullet, we aren’t going to be using it.
Next, lay our foundations by adding a rigidbody and an interactible script to the root object. Now add in a few colliders to represent the general shape of the gun. (Tip: You can put colliders on a child game object so that you can move it around)
Now it’s ready for us to start making grip points. The first one to do is obviously the trigger grip so let’s do that one. Drag in a Grab Handle as a child of the gun. Now for the tip I made this entire tutorial to give, positioning the Grab Handle perfectly. First, create a new pose on the grab handle so you can see the preview hand. Then position the Grab Handle so the hand is where you want it. Now I don’t know if this is how you’re supposed to do It, but before I was just putting the Grab Handel where I wanted it to be and then moving the pose hand to where I wanted it. The reason I like this method is that your rotations just magically sync up and everything feels a lot more natural.
After you’re done posing the hand move the collider so that it’s in the right place. Next set the angle limit if you want, I’m not going to since I want it to be easy to grab the main handle. Now we want to add the barrel grip, since that is the second most common grip. For this one, we are going to be using three grab handles: one for each side and one for the top. First, let’s do the ones for the sides, let’s do the left side first: position it using the same way as above and pose it so it looks something like this:
Now do that again for the right side so we can grip both sides. Now to make sure that our script can decide what grip to choose set Restrict By Rotation to true and set the angle to 45:
Also set Helper Grip to true, this is to tell our script that the trigger grip (or any other for that matter) should be in charge of the rotation of the gun.
At this point, we could stop. But we want our game to be like Boneworks. So Rinse, Repeat, make it look like this:
In fact, make it better than this! Put one on the barrel, and make some for different angles. This is all I’m going to do for now since I’m not putting it in a game. That’s it for now, I’ll see you in the next one. (comment if you want me to make it shoot!)