At function: _input help?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hunterh2o3

I need help figuring this out to make it work

https://www.deviantart.com/hunterh2o3/art/Screenshot-2023-05-19-181520-963256265

This is what im talking about

Hunterh2o3 | 2023-05-19 22:24

:bust_in_silhouette: Reply From: Tom Mertz

From the Node class docs if get_node can’t find your node. It will return null. That seems to be what’s happening to you.

So a couple things you can check.

  1. Is “Camera” the correct name of your node when you run the game?
  2. Is Camera a Node under the Player.tscn scene?

If 1 is true and 2 is false. You mignt need to run:

 get_tree().get_root().get_node("Camera")

to make sure you are searching through the entire SceneTree instead of just your Player node.

Hopefully this helps. Another thing you can try is caching the reference to Camera so that you are not searching the tree every frame:

var camera: Node
func _ready() -> void:
    camera = get_tree().get_root().get_node("Camera")

Then use camera.rotate_x on your input event