Global Access to player Node - godot tutorial

preview_player
Показать описание
In this tutorial you will learn how to set up code in Godot to allow global access to elements of the player node like the player nodes position no matter where the node is located in the scene.
Рекомендации по теме
Комментарии
Автор

oh my jesus - I have been watching tutorials and reading docs for a week to find this. Have a beer!

theobaynton
Автор

Thank you, thank you, thank you. Exactly what I have been searching for especially between scenes!

ReichelProductions
Автор

thanks so much bud!!!! you just gained a subscriber

zeekthegeek
Автор

Holy cow, thanks this helped me so much! Keep making good videos like this one :)

hartem
Автор

This is exactly what I've been looking for!! Thank you so much this video is an absolute life saver.

hurpo
Автор

Perfect tutorial, spot on, thank you!

intrinia
Автор

Idk if this is the same thing, but I made a game with enemy AI that has to access player node position .

first you put the Player node in group, then on enemy AI script you can write :

onready var player =

The enemy can now access the player node anywhere within the tree. Working in Godot 3.5.2

halimghani
Автор

The problem with this solucion is that you can't get a node like that in a _ready function since you cant really be sure of the order in which the _ready functions will be called.
So you could get a null exeption if the _ready function order is wrong.

Athrosus
Автор

Hey, you are the guy that has been doing BGE/UPBGE tutorials before... So you switched to godot. How do you feel about the switch? How is Godot compared to UPBGE in your opinion?

AnKlMa
Автор

Hmm, for some reason when I go to my AI script after making it global when I type print($) it doesn't auto populate or suggest root/global..

Hemoplaguer
Автор

Ma boi Hamilton is back with Godot. Have you taken a look at Armory for blender?

AlexCarby
Автор

no matter what I do, my code always returns the same value for the players position no matter where in the world it stands.
I'm trying to make a save and load system but when I load it prints the same position always
I think my code is getting my players position in something other than the scene its in

samuelhugo
Автор

I've been having issues with the "get_position" function. If I don't define it myself, it gives me an error saying that its not defined in base "nil". If I do, I get an error saying that it already exists in Node2D as well as the not defined error. Can anyone help?

DonQuixoteTheGremlin
Автор

So when the player moves, the AI prints the new position, or still printing the old position?

enemystandu
Автор

I realize this tutorial was done a few months ago, but since my stint with BGE I've finally migrated to Godot after a lot of life stuff taking time from my game dev hobby...I was wondering if you could do a tutorial on checking if an object has a specific variable in their script...like chooting a raycast from the player and accessing the script from the collided object to see if it has "health" or "locked" whatever...as a variable....


One further would be to check it's type(int, string, bool etc)... the coding is pretty easy, but there are not a lot of good coding examples in the documentation...when I was working on "myrlea" I would often look at others code(who doesn't :) ) to see how a specific function worked etc...anyway thanks for the tutorial and I look forward to more.

nowherebrain
Автор

Well, this helps but I want my enemy to move towards my player only at start. Means, when enemies spawn, I want them to move towrds me, if I change my position they should not follow me instead keep moving towards old position

ralsei
Автор

Im confused, aint this already all global?

Haykke