Firing at the direction the player is facing at

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By xdxdcookie

I am not sure how to approach this. I am trying to make a 2D top down game, but I am not sure how to get the bullet to shoot at the direction where the player is facing at. I looked up some stuff on google, but I am still confused. Can someone give me some hints on how to approach this? Thank you.

This is a post I found on reddit that seems really helpful, but one part is confusing for me:
"So a simple overview of what you need to do would be:

create a bullet scene, which consists of a kinematic body (named “bullet”), with a sprite and a collision body2d as children. add it to the group “bullets”

add a bullet script to your bullet node. It will be responsible for moving your bullet along a specified direction, which is a Vector2. In _process you’ll do something like move(direction * speed* delta). You can also add a kill_bullet function that will remove your bullet if it hits a wall, goes off screen, etc…

in your player script, when you hit the fire button, instantiate a new bullet and set its direction to the same direction as the player.

have your enemies look for collision with a body in group “bullets”, and take damage accordingly."

The part I am not sure what to do is how do I instantiate a bullet and tell it the direction the player is facing? Thank you for helping me out.

:bust_in_silhouette: Reply From: atopetrick

check out this tutorial of youtube channel KidsCanCode

https://www.youtube.com/watch?v=UKfzBnfh4Ak&list=PLsk-HSGFjnaFC8kEv6MaLXnnDcevGpSWf&index=4

This will explain how you can fire bullet where user is facing.

[comment deleted - thought you were talking about 3d]
Link here FPS tutorial — Godot Engine (3.1) documentation in English

paul.holt | 2019-03-25 06:28