0 votes

I can make the projectile spawn's but it just stay's there, and i can make it go to some direction's but not where the player is moving...

Is a top down 2D game...

Godot version 3.4
in Engine by (35 points)

2 Answers

+1 vote
Best answer

It somewhat depends on how you're handling motion in your game. I'd guess the accepted answer here should be useful to you. If that's not enough to get you going, I'd suggest you post (and properly format for the forum) the relevant code from your projectile and enemy scripts for additional assistance.

by (21,756 points)
selected by
+1 vote

If you are hand-designing your physics, you can use Vector2's move_towards to move the object in the direction of the player as they move.

var new_prjk_pos = cur_prjk_pos.move_towards(player.position, "some int value closer");

Link to Godot Article for method

If you are using sometype of Physics engine,

var direction_toward_player = project_pos.angle_to(player_pos)
var new_acceleration_of_projectile = projectile_acceleration.rotated(direction_toward_player)
projectile_acceleration = new_acceleration_of_projectile 

Vector2 Angle_To
Vector2 Rotated

by (98 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 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.