hehe, you just need to paste the code in as normal text and put [ code ] [ /code ] tags around it… there’s a button that does it for you on the advanced edit/post page.
Yeah I understand that part. What I’m trying to do is point to a block with the mouse and click on it then have him attack the block that I clicked. At the moment he only attacks the block that is in the “Public Gameobject Target”, but he needs to change his block selection when I click o new block.
screen to world pos check this. The you have to make a raycast from above that position down to your level. Then check if it is a valid block like Black Mantis said.
oh, hit.transform.gameObject will give you the transform/gameObject that was hit. You can also access the rigidbody and colliders via the raycasthit too:
use layerMask to make sure you are getting the hit only on the objects you want to test raycast on. and make sure those objects have the proper layer set in the inspector. because if you do not do this, the first object with a collider that was hit will get returned in hit info. by doing it with layer masks your raycast will ignore all the other objects that don’t belong to that specific layer.