public void UnsetCarryingItem() { if (carryingItem.GetComponentInChildren <BoxCollider>() != null) { carryingItem.GetComponentInChildren <BoxCollider>().enabled = true; } if (carryingItem.GetComponentInChildren <Rigidbody>() != null) { carryingItem.GetComponentInChildren <Rigidbody>().detectCollisions = true; } if (carryingItem is BuildingBase) { carryingItem.readyToUpdate = true; } else if (carryingItem is Item) { carryingItem.readyToUpdate = false; } float newScaleX = carryingItem.transform.localScale.x / AppConstant.Instance.moveBuildingScaleChange; float newScaleY = carryingItem.transform.localScale.y / AppConstant.Instance.moveBuildingScaleChange; float newScaleZ = carryingItem.transform.localScale.z / AppConstant.Instance.moveBuildingScaleChange; carryingItem.transform.localScale = new Vector3(newScaleX, newScaleY, newScaleZ); carryingItem.transform.rotation = transform.rotation; carryingItem.transform.parent = null; carryingItem = null; playerActionState = EPlayerActionState.IDLE; }
public void SetCarryingItem(InteractiveObject item) { carryingItem = item; if (carryingItem.GetComponentInChildren <BoxCollider>() != null) { carryingItem.GetComponentInChildren <BoxCollider>().enabled = false; } RemoveNearbyInteractiveGameObject(carryingItem.gameObject); //carryingItem.transform.SetPositionAndRotation(carryingItem.transform.position + this.transform.forward * 1.0f, carryingItem.transform.rotation); if (carryingItem is BuildingBase) { playerActionState = EPlayerActionState.CARRYING_BUILDING; carryingItem.readyToUpdate = false; } else if (carryingItem is Item) { playerActionState = EPlayerActionState.CARRYING_RESOURCE; carryingItem.readyToUpdate = true; } if (carryingItem.GetComponentInChildren <Rigidbody>() != null) { carryingItem.GetComponentInChildren <Rigidbody>().detectCollisions = false; } float newScaleX = carryingItem.transform.localScale.x * AppConstant.Instance.moveBuildingScaleChange; float newScaleY = carryingItem.transform.localScale.y * AppConstant.Instance.moveBuildingScaleChange; float newScaleZ = carryingItem.transform.localScale.z * AppConstant.Instance.moveBuildingScaleChange; carryingItem.transform.parent = this.carryingPivot; carryingItem.transform.localPosition = Vector3.zero; carryingItem.transform.localScale = new Vector3(newScaleX, newScaleY, newScaleZ); }