+1 vote

I am working on a fps hitscan gun that is a separate scene from the main player(KinematicBody).
The problem is that the raycast varies from gun to gun because of the possition of the gun,but I want the player to, no matter where the "bullet" is comming from, it will always be directed to the center of the screen.
To that end, I need to "connect" the gun raycast to the player raycast so all the guns will shoot towards the same point.
The problem is that when I try to call the player raycast node this message appears: onready var aimcast = $Aimcast// get_node: Node not found: Aimcast.
How can I call the AimCast node from the gun scene?

in Projects by (16 points)

2 Answers

+1 vote
Best answer

How about you give this a shot ?

onready var aimcast= get_parent().get_node("AimCast")

I'm pretty new myself and not sure if it'll be something that's considered a good practice but you can save the AimCast as sperate branch by right clicking on it and selecting "Save Branch as Scene" and then instancing that to your scene where you want that. Then you can make that AimCast Local and make necessary adjustments or changes to it locally there. This way the above code should also work.

by (403 points)
selected by
0 votes

The simple way is this =


The longer way is this =

Remove the current level

var level = root.get_node("Level")

Add this

Add the next level

var next_level_resource = load("res://scene.tscn)
var next_level = next_level_resource.instance()
by (19 points)
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.