Hello.
I’m raycasting on an object whom has a parent and I want to access a component on the parent, how do I do this?
this code:
void Update () {
Cylinder otherobject;
RaycastHit hit;
Vector3 angle0 = transform.TransformDirection(Vector3.up);
if (Physics.Raycast(transform.position, angle0, out hit, 1)){
otherobject = hit.collider.gameObject.transform.parent.GetComponent <script>().something();
}
}
How can I access a function on the script? the error I get:
Cannot implicitly convert type void' to Cylinder’
How can I fix this?
Thanks!