The thing here is that I want to modify it so that the arrow projectile would land on a moving object. The arrow would be instantiated by an archer that is not controlled by a player but by script, basically like a bot. I want to set the target position to the enemy’s global_position.
It shows in the tutorial that the arrow’s path trajectory follows a constant path laid out through path2d but I want it to change constantly based on the enemy’s position and wanting to set the value of the set_point_in() to the enemy’s global_position. Is that doable in godot right now? How do I start implementing this? Thanks in advance!
So I have some homing missiles that follow the player. The players position I write to a global script I call “PlayerManager”. The weapons that need it, just read the target location from that same file.
Another of my weapons called “SpikeyBalls” does it differently. They too home in on the player ship. When they are instantiated I write the Player node reference to a variable in the weapon script before I add them as a child of (in my case) “EnemyWeaponsContainer”. They just then use that Node reference to get a target position.
I have kinda gone off the first method, and now prefer the second method. But at the moment I have not, and probably will not, go back and change the PlayerManager global, as it is also used to track how far the player is from the target location etc for the UI components.
Hope that helps.
PS In the case of an arrow, do you really want it to home in on the player? Having it follow a parabola would seem more normal to me. You could just shoot 4 arrows to give you a nice spread. In my case these are missiles and alien weapons in space, so homing makes sense. Anyway, just thought I would mention it.