I'm trying to make a preview of where i want to place something in the world the whole shell that is slightly transparent and no physics my problem is that my code does make a preview (i haven't done the removing physics and making it transparent part yet but i will) but the next time it places it it places it on the last one it previewed?
Destroy(preveiw);
if (Screen.lockCursor == true)
{
if (inventory.equiped.itemName != null)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out hit);
Debug.Log("hit" + hit.point);
Debug.Log("was " + hit.distance.ToString() + " away");
}
if (inventory.equiped.itemName != null && inventory.equiped.itemType.ToString().EndsWith("Getable"))
{
if (hit.distance < 6)
{
if ( hit.rigidbody.name != preveiw.name)
{
preveiw = Instantiate(Resources.Load("block/" + inventory.equiped.itemName),hit.point, Quaternion.Euler(0,rotationParent.transform.eulerAngles.y,0)) as GameObject;
}
}
↧