11 hours ago, LifeIsGood said:
Yes. The dot product is defined as
Thank you very much. I can solve math easy on paper so I can use it easily but I am not aware of how it impacts the computer, or what version of the formulas is used on computer that is optimal.
Allso as a none programer I have no idea what is CPU friendly.
10 hours ago, lawnjelly said:
Is there no friction in the environment? Usually friction can take care of this problem for you.
It's a space game so I use no friction. However, enabling friction to get around this could be worth it. Will try it soon.
10 hours ago, lawnjelly said:
Is the force being applied every tick?
Yes, both my ships and projectiles have acceleration, so I need to adjust the amount of force every frame. Some projectiles also have other behaviors that need forced adjusted each frame.
10 hours ago, lawnjelly said:
I'm assuming this is all profiled, and you are sure on what is the bottleneck.
Yes, it is all profiled. After my little polygon mistake from last time I switched to a better workflow, now profiling as I go.
One of my aims is to get a lot of moving objects with complex interactions, to makeup for the fact that the game doesn't have a lot of content. So stress testing and profiling is a constant part of the workflow.
My problem is that I am running huge amounts of projectiles at a time. So even a small optimization in one gives back a lot of performance. The game is going to have "pinball" feel to it, that will have lots of content flying around and such, so I am doing basic optimizations; nothing drastic.
9 hours ago, Kylotan said:
In Unity you can just use Vector3.sqrMagnitude - no need for the manual dot-ting.
You probably also want to consider Vector3.clampMagnitude to keep your velocities from getting too high, as opposed to manually doing the comparison and modification yourself.
So that is where it is! Thanks, I have been looking in the math library this whole time.Vector3.clampMagnitude is new to me, definitely worth a try.
9 hours ago, turanszkij said:
Have you tried "Carmack's" fast inverse square root? Personally, I haven't but I'd like to hear if you find it faster:
Thanks for the link, will add it to the list.
8 hours ago, lawnjelly said:
In this case though, if you want to just limit a bunch of velocities, there may be no need for a square root unless the value is over the threshold, unless you want to make it branchless (again profiling is key, and may depend on the data set).
Yes, looks like I have a busy weekend before me.
Thanks for all of the help. I don't know how much of this I will use to directly solve my problem, however I know that all the information here should prove useful as I advance with the game.
This is a huge new jem of information for me. Thanks. ![:) :)](https://uploads.gamedev.net/emoticons/medium.smile.webp)