Hello !
I’m new to this engine and I’m having a issue with the look_at() function.
I’m trying to make the player shoot a bullet in direction of the cursor
This is my code for the bullet :

extends Area2D

@export var SPEED := 5000

var movement_vector := Vector2(0,-1)


func _ready():
	look_at(get_local_mouse_position())
	

func _physics_process(delta):
	global_position += (movement_vector.rotated(rotation) * SPEED * delta)

And my code to shoot it (inside player scene) :

##SHOOT
	if Input.is_action_just_pressed("shoot"):
		var bullet_instance = bullet.instantiate()
		get_parent().add_child(bullet_instance)

But the bullet is not going where the cursor is
(if you can please help locate the bullet too :slight_smile: )

https://youtu.be/hhqh5lKO06U

    TheMikega Please put your code between ``` tags to format it properly.

    You probably want global mouse position, not local.

      xyz (the code is now proprely formated)
      But even after changing to global_positions I'm still having the same issue.
      I also forgot to give a screenshot of the scene and his tree but I don't think the issue come from here.

      • xyz replied to this.

        TheMikega Let your bullet look down the X axis instead of Y axis.

        xyz
        I made it work for some reason ?
        I manualy changed the rotation by 70.7 (degree ?) :

        global_position += (movement_vector.rotated(rotation+70.7) * SPEED * delta)

        and rotated the sprite to put it on X axis like you sayed and it worked !

        • xyz replied to this.

          xyz
          Radians to degrees, I am having flashback of my math class
          Thank you !

          • xyz replied to this.

            TheMikega That was 70.7 radians. Which is 4050.8 degrees. When you divide that with 360, you get 11 full circles and a remainder of 90.8 degrees. This represents the final angle of 90.8 degrees. What you probably wanted was exactly 90. In radians that's half of PI.