- Home /
Move and Rotate picked up object
Hi, I've been following this tutorial : https://www.youtube.com/watch?v=JtflOvhOO1Y. Instead of the simple box I'm trying to hold a barrel from this asset : https://assetstore.unity.com/packages/3d/props/industrial/barrel-840. Character picks up object but unfortunatelly its rotated, so while holding it i see the bottom of the barrel and i would like to see the side. Also, the barrel is to close to the face, so it covers almost all of the screen. I've been trying to add or multiply some values in "guide.transform.position" and "guide.transform.rotation" but it doesn't work. Can you please tell me how to move barrel further from my face and also how to rotate it to see the side of it ? Thanks !
public class MoveObject : MonoBehaviour {
public GameObject item;
public GameObject tempParent;
public Transform guide;
// Use this for initialization
void Start () {
item.GetComponent<Rigidbody>().useGravity = true;
}
void Update () {
}
void OnMouseDown()
{
item.GetComponent<Rigidbody>().useGravity = false;
item.GetComponent<Rigidbody>().isKinematic = true;
item.transform.position = guide.transform.position;
item.transform.rotation = guide.transform.rotation;
item.transform.parent = tempParent.transform;
}
void OnMouseUp()
{
item.GetComponent<Rigidbody>().useGravity = true;
item.GetComponent<Rigidbody>().isKinematic = false;
item.transform.parent = null;
item.transform.position = guide.transform.position;
}
}
Your answer
Follow this Question
Related Questions
How to move camera up and down 1 Answer
Why is the animator not changing the position but only changing the rotation? 0 Answers
Change object position on trigger enter 3 Answers
Treasure Chest Problems 1 Answer
Rigidbody constraints in local space? 7 Answers