+2 votes

Hi,

I'm building a thing where I'm using the great lerp camera by kidscancode. I thought I'd use the same camera for different objects.

I'm trying to create "an entering a vehicle" mechanic where when the player presses the action button the camera switches over to the vehicle and the control set for that vehicle is activated at the same time deactivating the player objects control.

I have figured out switching the camera is a rudimentory way:

func get_input():
if Input.is_action_pressed("action_A"):
    target_path = get_node("/root/World/PolyPlane")
    target = target_path

I would now like to set the input for PolyPlayer inactive and Polyplane active. Since this is the camera's script, I am unable to get and set the script variables I've created for the PolyPlane and PolyPlayer which I want to toggle.

Also, I want the camera to read and set the offset variables from those two objects (Which I will set individually in their scripts) when switched so this is also something I hope can be accomplished in some similar way.

ProjectTree

Script Variable

Camera Switching

Godot version 3.3
in Engine by (27 points)
edited by

1 Answer

+2 votes

Kids can code also has a great article on node communication that is very well worth the read: http://kidscancode.org/godot_recipes/basics/node_communication/

Be sure to check out the diagram linked in the info box at the top!

I would think that since you're communicating between siblings you would emit a signal. You may also consider creating an auto-load singleton that handles your input gathering that other nodes can query to see the current input status.

by (3,707 points)

Thanks for the reply. I did come across other resources that point to how to identify and get node names and variables.

I will look into auto-load singleton though I'm very new at this and all of what you said is difficult to understand.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.