The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hello everyone,
i will start with my problem that is strange. I started with Godot engine a couple of weeks ago and i was trying to create something after watching tutorial videos.

Well, my problem is, when i try to combine a cannon and a squared character from tutorials to create something like a character with weapon, it works very strange.
I tried to add a cannon to rotate so it could fire in different directionsscene
but now cannon balls spawn under the platform.square and cannon

Separate they work, but together not and i don't know why.

(Sorry for bad english)

in Engine by (12 points)
recategorized by

I'm working on this rn, if I get it working to a polished level I'll publish as a plugin.

2 Answers

+1 vote

Instance the balls on the level, not as children of the gun/player (maybe you are already doing this).
Then use global position (get/set_global_pos) to place them on absolute coordinates.

Sometimes you may want to use global rotation too.

by (7,890 points)

Sorry, i donĀ“t understand what you mean

Something like:

var cannonball = Cannonball_scene.instance()
0 votes

Your bullets are spawning in the place where the gun was positioned originally. Before instancing them set their position in global coordinates.

Also check what the other user said, add the child bullets to the root node, not to the player. The easiest way to do that is get_tree().get_root().add_child(bullet)

by (372 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.