- Home /
Joint pick up script joint not being set to z of the object picked up
So like the title said I made a joint script that picks up the object when you click on it. var wantedPos = Camera.main.ScreenToWorldPoint (new Vector3 (mousePos.x, mousePos.y, carriedObject.transform.position.z)); target.transform.position = wantedPos;
The only problem is that.. Well it gets the z of the carried object when you click and it works fine.. The first time.. Then if you walk backwards after you let go then carry the object again. The joint stays in the same distance from the player instead of updating to how far away it is now. I want to try and make it I can take the carriedObject.transform.position.z
outside of the Camera.main.ScreenToWorldPoint
the problem is that I would have to make a new vector3 for that and it would make it so I can't control with the mouse. I'm new to doing this sort of thing so can you help me?
Your answer
![](https://koobas.hobune.stream/wayback/20220612124823im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
View an array of the transform position/rotation of all game objects with a specified tag., 0 Answers
GameObject positioning in World Space 2 Answers
Fixing instantiated object in one direction? 0 Answers
How can I define a joint for my ragdoll? 0 Answers
Wrong positioning of game objects after instantiating them 0 Answers