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)

asked May 4, 2017 in Engine by Undead_Rufus (12 points)
recategorized May 4, 2017 by Undead_Rufus

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.

answered May 4, 2017 by eons (7,784 points)

Sorry, i donĀ“t understand what you mean

Something like:

var cannonball = Cannonball_scene.instance()
cannonball.set_global_pos(cannon.get_global_pos())
node_where_cannonballs_are_placed.add_child(cannonball)
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)

answered May 9, 2017 by rredesigns (365 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.