Either Unity has gone haywire or its me !! Please help

simply basic problem but I have been stuck in this rat hole for the last 2 days, finally found out that my script wasnt working because the get component part was not working , but when I attach the reference to the component of the gameobject via the unity inspector it works.

Below attached is the get component script image that is not working even though everything look fine ,and there r no errors. Kindly help .

Well, the first two questions that come to mind are:

  1. Does the player gameobject have a ClickToMove component attached?
  2. Is there really only one gameobject with the “player” tag?
1 Like

Is the mouse connected to your computer?

1 Like

1.Yes there is ClickToMove component on the player gameobject and when I am using the inspector to attach the script to the public variable , everything works fine and on mouse click the component gets disabled and the button text changes.

2.and yes there is only one gameobject with player tag , and my mouse works perfectly.

Try it in void Update() instead of protected virtual void LateUpdate(), maybe that could be a problem.

1 Like

Your Start method is incorrectly written as start so that code never runs.

3 Likes

KelsoMRK … thanks a ton ! You have eye sight better than the eagle. cheers . Yes that was indeed the problem.It was such a trivial thing and I was stuck in the rat hole for 2 days ! phew … again realized how much more I have to learn. Thanks everyone for the support .