- Home /
Get component of gameobject of parent returns null
Project setup
Script In AimArrowStuff:
CharContrl cs = gameObject.GetComponent () as CharContrl;
How can I fix this? (Ignore input errors please :D )
Can you post your DrawAi$$anonymous$$gLine script? because use of gameObject.GetComponent() will check for that script on the same object to which this script is attached to but from the image it seems like these two are on different objects.
They are not showing because you are in plain html so
<>
are removed and considered as formatting.
Answer by fafase · Jan 22, 2015 at 06:21 PM
At first sight, you are trying to access the CharControl with:
gameObject.GetComponent<CharControl>();
but that would mean the other script is on that same object and I don't see any DrawAimingLine on this game object.
If the two components are not on the same objects you first need to find the other one and this has 1000 of answers here.
Your answer
![](https://koobas.hobune.stream/wayback/20220613181159im_/https://answers.unity.com/themes/thub/images/avi.jpg)