I honestly don’t even know how to start to begin to explain everything wrong with everything you have written there.
Your code is disorganized, named poorly, and generally enigmatic to determine what any given line of code even means.
Let me suggest some guidelines:
-
Name a function for what it actually does. This function does not just create, it creates and does a bunch of other stuff. If what it does is too complex to describe, document what it does in a few short sentences.
-
the parameters that get passed into the function should be named something that makes sense. What is ‘position’ and ‘targetPosition’? What do they represent?
-
Don’t split half the work between two places arbitrarily. If Create is supposed to do the work of placing something in a circle, and applying some trajectory relative to that circle (only reason I could think of passing in the center of the circle and its around the circle), then it should do that. Not do half of that and expect the code that calls it to do all the work for you.
Naming is your big problem here. Think about it this way… when you name something, name it in a manner that you couldn’t easily open up the file and read the code inside of it. If from the name, and short sentence or 2 describing said class or function is not enough to get a general idea of what’s going on… your function is not named well… if you can’t think of a name and short description for it, then it’s designed poorly.
So your Create method.
What is the ‘position’ parameter? Because you’re passing in the position that is the center of the circle, but the Create method uses it as the position where the projectile gets instantiated.
What is the ‘targetPosition’ parameter? Because you’re passing in the calculated position on the circle that I THOUGHT was where the projectile should be spawned. But you use it as a paramter to yet another unknown function ‘Rotate’ that is used as the rotation of the instantiated projectile, as well as to determine the trajectory the projectile takes. But NEVER as the position it starts at! So of course it doesn’t appear in the position you expect, you never set it to the position you expect.
I’m not going to even get into the ‘caster’ and ‘damageRatio’ parameters, especially since you don’t even use them in the function.
Note, I’m not asking these questions for you to answer them to me. I don’t care, honestly. I’m asking in a rhetorical manner. These are things you should be asking yourself! You wrote this function, yet you called it by passing in the wrong parameters to the wrong slots.
Remember that whole about writing a function with names that make sense? Yeah… even you, the author of this function, don’t know how to call it correctly because the name and design is so convoluted. How do you expect us to know how to solve your problem, with out even seeing the code?
Your code inside of Create calls even more functions and properties (Extensions.Rotate, targetPosition, Kill). I have NO idea what these functions and properties do. Do you? Because I’m weary as to what they do as well that might cause more issues as to why your projectiles show up in weird positions.