- Home /
I want to access Vector.down of my array Object but, I am unable to find a way to access it............ Have any clue??
Vector3 vec=_array[0].GetComponent(); if (Physics.Raycast( _array[0].GetComponent().position, _array[0].GetComponent().dow, 3f)) { p1_PhysicsHandler += () => state = g1_States.gamestart; p1_InputHandler += () => state = g1_States.gamestart; }
Answer by Bunny83 · Oct 18, 2020 at 09:53 AM
Vector3 is a struct, a pure data type that holds 3 float values. It's not a Component derived type and can not be attached as a component to a gameobject. So I'm not sure what you're asking because your code doesn't make much sense. If you want to get the relative "down" vector of the Transform of the gameobject you have to use the "up" property of the Transform component and invert it to get the down vector since the Transform class doesn't have a dedicated "down" property. You should do
Transform trans = _array[0].transform;
if (Physics.Raycast(trans.position, -trans.up, 3f))
{
// [ ... ]
Your answer
Follow this Question
Related Questions
Access a GameObject through it's tag, using a string. 1 Answer
Accessing variables from a different gameobject 1 Answer
Can't Access Prefab Script from FPS Controller 0 Answers
Limiting respawns on scene 1 Answer
GetComponent: Easy help 1 Answer