# Needing Help on How to Interact With Screws/Screwdriver,How to Make a Screw/Bolt Interactable with a Screwdriver

Hello,

I am new to Unity and was trying for my first project to interact with objects. The example that I am wanting to do is having a sheet of metal with 4 holes that I have already made. But with the 4 holes I would like to have a screwdriver interact with the screws and being able to actually screw into the sheet of metal. I just don’t know where to go from here honestly. I don’t know what type of script I need to make, what components to add to the screws, what video’s to watch or to learn, any help on this would be much appreciated. Here is the model of screws as well that I’m trying to use for project:

TLDR: Trying to interact with screws/screwdriver don’t know how, help please.

Thank You!

A full tutorial is beyond the scope of a post here, but a few main points should suffice to get things moving.

Given the caveats in my comment that this is not likely a good choice for a beginner, start with just the screw.

Place the wall in an orientation where it is aligned with the world axis (the wall should not be rotated relative to the axis, the wall should be one of the axis aligned planes). This is necessary so as to simplify the rotation of the screw. Next, place and align the screw to a hole into which is should be driven, with the tip of the screw touching the hole.

Attach a script to the screw object which will operate the screw’s motion without physics. Search for how to use Time.deltaTime. Create a float representing the rotation of the screw (starts out zero). Using the editor, figure out which of the 3 localRotation values rotate the screw in the direction of a screw turning the same way as being driven by a screwdriver (which comes later). Fashion code in the Update function of the script (not FixedUpdate since this isn’t using physics), so that the screw’s rotation (the float) increases gradually over time (using Time.deltaTime), and apply that using the eulerAngles property of the screw’s localRotation. This should make the screw turn. Adjust so the speed makes some sense.

The screw will turn without end like a wheel or gear at this point. Next, add to the script a motion of the localPosition property of the screw so that it moves slowly toward the wall while the screw is turning. Create a float for this speed like the one used for rotation of the screw. Adjust these two values, the speed for turning the screw and the speed for driving the screw toward the wall until the appearance is reasonable.

Observe and test for the point at which the screw is fully “in”, so you can then sense this in Update and stop the rotation and the drive motions - the endpoint of screwing the screw into the wall.

Once completed, you can place and align the screwdriver so it is positioned appropriately relative to the screw, then apply the same rotations to the screwdriver. This can be done by temporarily making the screwdriver a child of the screw, or you can duplicate the Update function to independently control the screwdriver and the screw. Either way, you’ll need to fashion a way to start this ‘animation by code’ and then after the screw stops, remove the screwdriver (which may also require you to ‘deparent’ the screwdriver from the screw if that approach is used.

I realize that for a beginner this may be more than makes sense at first. This reflects the fact that this is more than a beginner should consider.

Now, I should point out that while you’ve said you want to start out small, I think you’ll need to start out smaller. I’ve attempted to incorporate that notion in the means by which the screw is made to operate (separating rotation from driving). There are lots of ways to implement this concept, including making animations in Blender or 3DS Max, using them for the motions involved instead of coding.

Hello,

Thank you for replying to this I really appreciate all of the feedback/help I can get! I’m sorry but, would you be able to explain it to me so I can understand it better? I’m glad you went into depth in this it shows that you took the time to type this out for me which I appreciate! But I’m really new to unity and just don’t know where to start the process of trying to screw something into say a wall. The project I’m trying to work on is a training simulation on how to build a pump. So I would like to start small with trying to put a screw on a screwdriver to then screw it into a part. Would you be able to help on where I should go from here or what actions I should try? Thank you for all the help/feedback I honestly appreciate you taking your time in helping me it means a lot!

No worries, hope everything goes well. Thanks again for the help, very much appreciated!

@Kingsburry if you solved that problem can you help me