C# noob question (array realated)
How to get WhatRayHited.distance of frontbotleft, i want to use it for somthing?
i want to calculate WhatRayHited.point of frontbotleft - WhatRayHited.point of backbotleft
void FixedUpdate ()
{
Vector3 frontbotleft = transform.TransformPoint(new Vector3 (0.51f,-0.4f,-0.51f));
Vector3 frontbotright = transform.TransformPoint(new Vector3 (0.51f,-0.4f,0.51f));
Vector3 backbotleft = transform.TransformPoint (new Vector3 (-0.51f,-0.4f,-0.51f));
Vector3 backbotright = transform.TransformPoint (new Vector3 (-0.51f,-0.4f,0.51f));
Vector3[] cornerp = {frontbotleft,frontbotright,backbotleft,backbotright};
for (int i = 0; i < cornerp.Length; i++)
{
RaycastHit WhatRayHited;
if (Physics.Raycast (cornerp[i], -transform.up, out WhatRayHited, 10f)) {
//WhatRayHited.point of frontbotleft - WhatRayHited.point of backbotleft
//I have other code here that i need so i dont want to brake arrey
} else {
//Nothing
}
}
}
Answer by dudester · Oct 09, 2015 at 07:37 PM
WhatRayHited.distance
is what you need here should give you a distance for the hit. then to get a specific one like topleft do like so ,if(cornerp[i]==frontbotleft) //then do distance check WhatRayHited.distance,
i redit the question but anywey your answer WhatRayHited.distance outputs for every raycast from cornerp so it does not give me specific ones
oh i see , well then just say if(cornerp[i]==frontbotleft) //then do distance check WhatRayHited.distance
editing answer to reflect this
Thank you so much that is what i wanted YEY f i dont have any point now to give you but when i acure some will come b to reward
Your answer
Follow this Question
Related Questions
Array of Arrays 3 Answers
Crear un arreglo de una clase en otra clase 0 Answers
All crops in list growing at once when they are supposed to grow individually 0 Answers
Keep track of last audio clip played from multiple arrays 1 Answer
How to place a property underneath some other properties (property drawer of serialized object)? 1 Answer