- Home /
Weapon not updating position and moving as Player moves
Hey all. So when I press E on my weapon it is supposed to reset the position to completely 0 and then parent itself to the WeaponParent object in my hierarchy. Although it does parent, it does not update the position. If I am to update the position myself then my weapon will move as my player moves. This is my gun pick up script. Thanks
public void GunPickUp()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Input.GetKeyDown(KeyCode.E))
{
if (Physics.Raycast(ray, out hit, 3f))
{
if (hit.transform.tag == "Weapon")
{
hit.transform.parent = GameObject.Find("WeaponParent").transform;
hit.transform.position = new Vector3(0, 0, 0);
}
}
}
}
Comment