0 votes

Hi! I'm currently using this solution:
Currently, it doesn't aims to the player well, and I don't know how to fix that. It always aims off.
Thecnical stuff:
I'm rotating a vector2 (radius) and spawn the bullets at it's position. I'm making a regular node (center) lookat() the player, and add it's rotation to the vector2 (radius)
(The player and the enemy are KinematicBody2D-s and the bullets are Area2D-s wich have their global
position updated.)
I'm using a lot of ideas from this queastion'S 2nd aswer:
https://godotengine.org/qa/12826/spawning-objects-around-a-circle

This is how it aims: (The flame thingy shows the rotation of the center,
but as you can see, the bullets are not spawned at a correct position)
enter image description here

And this is how it should work: (The lines are just helping to visualize)
enter image description here

(If you need any more information, just say it, because I don't know what else to say.)
BTW the visuals will be worked on after I will fix the main BUGs in the game. (just like this one)

export(int) var shoot_angle = 90  # in degrees
export(int) var numb_of_bullets = 3
export(float) var time_between_shots = 0.5
var radius = Vector2(100, 0)
onready var center = get_node("Center")
var angle_step = shoot_angle / numb_of_bullets

center.look_at(player_node.global_position)

for i in range(numb_of_bullets):
    var spawn_pos = center.global_position + radius.rotated((center.global_rotation / 2) + angle_step * i) # * sign(center.global_rotation / 2))

    var node = bullet.instance()
    node.global_position = spawn_pos
    get_parent().add_child(node)
    node.move_direction = global_position.direction_to(node.global_position)
in Engine by (137 points)
edited by

If you need any more information

For starters a bigger image would help. Or a better description of what's happening: "doesn't aim [...] well" can mean a lot of things. Furthermore it would be helpful to know the node-types you're using (for the player, enemy and bullet) and how the variables shoot_angle, numb_of_bullets, center and radius are defined.

Thanks! You're right...

Now You can have a look at it ;)

Please log in or register to answer this question.

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.