I have 2 blocks, Block A is the player, Block B is part of a cube grid floor. I want to get the position of Block B from Block A. There are many Block Bs in the Scene.
I’m able to destroy the specific Block B the player is above (I’m using forward on the raycast this is correct), but can’t get it’s position. S o Ican zip around deleting the floor as I go, but can’t get the position of any of these game objects
private float rayBlockCheckDistance = 10;
private void gridSnap()
{
RaycastHit[] hits;
hits = Physics.RaycastAll(transform.position, Vector3.forward, rayBlockCheckDistance);
GameObject gFloor = hits[0].transform.gameObject;
//Transform tFloor = gFloor.transform; //This Errors
//Vector3 position = new Vector3(tFloor.position); //So this Errors aswell
Destroy(gFloor); //But I can destroy the specific Block fine.
}
No errors are given for why I can’t apply transform as thus get the position of the first object in the raycast array, the Editor just flashes “Compiler errors”, but no errors are given in console or VS.
Both objects have box colliders/rigid bodies.