0 votes

this is the full code

func fire():
var bulletinstance = bullet.instance()
bullet
instance.postion = getglobalpostion()
bulletinstance.rotationdegrees = rotationdegrees
bullet
instance.applyimpulse(Vector2(), Vector2(bulletspeed,0).rotated(rotation))
gettree().getroot().calldeferred("addchild",bullet_instance)

someone please help. thanks

Godot version 3.4.2
in Engine by (15 points)

2 Answers

0 votes

The error message "isnt declared in the current class" means the type of node you have chosen doesnt have this property. A kinematic body would have this property for instance but a basic node wouldnt. What kind of node is your bullet made of?

by (3,324 points)
edited by
0 votes

To fix your error, you need to change node's script owner to Node2D or it's descendants (and add extends Node2D as first line of your script) class.
get_global_position is defined in Node2D class. Based on your script, your node is extended from Reference (if your script has no extends keyword, then your script extends Reference).

by (1,650 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 Frequently asked questions and 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 [email protected] with your username.