#Using Signals to pass position/rotation data?

8 messages · Page 1 of 1 (latest)

lavish needle
#

I'm trying to follow FinePointCGI's tutorial on character movement. (link: https://www.youtube.com/watch?v=eGt7ikx7FcQ)

However, I have my camera and player as two separate scenes. So using groups to get the position and rotation data isn't working as it is in his example. I'm trying to use signals in place of the groups, but I keep getting this error: 0 - res://Scripts/camera_rig.gd:5 - at function:.

I can't really find a thorough explanation for what's going on here through google; or the information just slides right off my smooth brain.

The picture includes the code I'm trying to glue together, the lvl_0 scene tree, and my player signal script is literally just these two lines:


signal orientation(player_loc)

Can someone please explain to my smooth cave man brain what I'm doing wrong, and how to get this to work?

I've been struggling with this for a long time. So much so that I've just put the project off almost entirely. I would really appreciate the help!!!!

Subscribe and learn more from me about Game Development and Programming!

In this video, we talk about how to make a 3d character controller in Godot 4! We talk about how to do animations and how to handle collisions with the camera!

RESOURCES
Source Beginning: https://github.com/finepointcgi/3D-Movement-Tutorial-Godot-4/tree/Start
Source End: ...

▶ Play video
#

I forgot to mention; I've tried just passing (vector3) in the orientation signal. I've tried passing global_position. I can't figure out why it won't work. 😭

#

I could always follow FinePointCGI's tutorial to the letter, and not have my camera as an independent scene, but I question if that's the best thing to do. I have a feeling that keeping the camera as a separate scene is the best option.

I also believe learning how to pass that position information with signals will help me understand them better anyway, but geez I'm so lost. 😭

#

i forgot to emit the signal.

lavish needle
#

I'm getting somewhere but it's still not working.

#

I put these lines in my player_controller script

        emit_signal("mouse_movement")

And this is my camera_rig script now.


var player

func _on_character_body_3d_mouse_movement() -> void:
    player = get_tree().get_nodes_in_group("CharacterBody3D")[0]

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
    global_position = player.global_position
#

And this is the error I'm getting
Invalid get index 'global_position' (on base: 'Nil').

patent haven
#

Where you emit the signal, you can use the new syntax: orientation.emit(signal_args). If you connect it through the editor to another node, it will create a function with as many inputs as there are outputs on the signal, and you can access the data from them.