Quantcast
Channel: Latest Questions by TwitchBlade
Viewing all articles
Browse latest Browse all 6

i would like to create a preview of an instantiation but im haveing a problem with my code

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>