Hey, I’m a new game developer and I an just beginning to learn about how godot’s script works, and I thought I had figured some basic stuff out, but it’s giving me errors and I’m clueless.
As I just started, I wanted to make a simple game, and so I started making geometry dash in 3d.
I have a few questions relating the scripting that I would really appreciate some help with.
I tried to use .velocity.y += 5 to bounce the player upwards, but im getting errors like “This line has no effect” even when it used to work.
Here is my current code that doesn’t work: ??? - Pastebin.com
I would also really appreciate it if someone could tell me what I did wrong.
(Here I tried making the yellow booster orb from geometry dash that boosts the player up when they use the jump key while touching the orb)
I’d like to know how to ‘teleport’ or instantly move objects (or the player) to different locations in the same scene.
I’d love to know how to get a global variable referencing the player, so that “player” in any script will be directly referring to the actual player.
Thanks in advance to anyone who helps, I appreciate your time.
The first line serves no purpose as it is immediately changed to something else, unless you want to reset it? Which might be what you want. Unless it’s x you want to set to 1, not y… which then would be a typo.
target.velocity.y == 1
target.velocity.y += 8
I know of Geometry War, but never played it.
To move things around the world, just set their position to where you want them to be. Usually through an invisible marker on the map.
As for the last, one way would be to use a singleton that you autoload and then set a player variable inside that singleton once the player is created. From that singleton, you can call the variable.
#Somewhere in code
Singleton.set_player(player)
# In some class or .gd
some_object.position = Singleton.player.position
# Or something like that.
1: You have an extra equal sign, use target.velocity.y = 1 instead of target.velocity.y == 1 .
but this: target.velocity.y = 1 target.velocity.y += 8
is the same as this: target.velocity.y = 9
2: You can “teleport objects” by setting the global_position of a Node (should be a Vector2 or an Vector3.)
3: Any variables defined at the top of one script can be accessed from other scripts. Setting a var in one Node: Using it in another: