godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.98k stars 21.16k forks source link

Rotation of nodes being instanced #76682

Closed Tabascus closed 1 year ago

Tabascus commented 1 year ago

Godot version

4.0.2

System information

macOS 13.3.1, Radeon Pro 5500M, Vulkan

Issue description

(I'm new here please be nice)

I'm in the middle of a course over on GameDev.TV in particular a lesson where I need to shoot a rocket from the ship. The asset is positioned correctly in the folder as is the Transform settings for the scene and asset in the scene, however when shooting the rocket it points downwards instead.

Screenshot 2023-05-03 at 6 05 30 am

The node is set to 0 degrees rotation as shown here:

Screenshot 2023-05-03 at 6 24 19 am

I have found the fix for this which was to add in rotation_degrees = 270 to the rocket.gd at the bottom. So I'm not sure if it's a bug or not, but definitely not what the instructor experienced in the video.

Steps to reproduce

For player.gd I was advised to add the following:

func shoot(): var rocket_scene = load("res://Scenes/rocket.tscn") var rocket_instance = rocket_scene.instantiate() add_child(rocket_instance)

And the code I have for the rocket.gd:

extends Area2D

@export var speed = 300

func _physics_process(delta): global_position.x += speed * delta `

Minimal reproduction project

GameDev.TV Alien Attack.zip

Calinou commented 1 year ago

If your rockets are children of the ship, they will move and rotate along with the ship. Instance the rockets in the parent node of the ship instead (get_parent().add_child()) to avoid this, or call set_as_top_level(true) on the rockets just before using add_child() on them (which will make them not inherit the parent's transform).

Either way, please don't ask support questions here, as this issue tracker is meant to be used for bug reports only. Use one of the other community channels instead.

Tabascus commented 1 year ago

Thank you, I’ll try that out. Apologies as I assumed it was a bug due to the rotation situation.

On 3 May 2023, at 6:45 am, Hugo Locurcio @.***> wrote:

If your rockets are children of the ship, they will move and rotate along with the ship. Instance the rockets in the parent node of the ship instead (get_parent().add_child()) to avoid this, or call set_as_top_level(true) on the rockets just before using add_child() on them.

— Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/76682#issuecomment-1532161843, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3BCTM5YZ6ETSYILRIOHJYLXEF2PHANCNFSM6AAAAAAXTR5QAY. You are receiving this because you authored the thread.

AThousandShips commented 1 year ago

See here

Tabascus commented 1 year ago

Thank you kindly! And again apologies for posting this as a bug report. On 3 May 2023, at 7:45 am, A Thousand Ships @.***> wrote: See here

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>