Another good one dude, keep it up! I'm not too familiar with Unity's blend spaces (and actually Unity's 3D anim system in general). Does it have support for event-track based animation sync? If so, that would be a good next tutorial if you don't already have one planned!
Yea, you don't really ever want to change that timestep unless you're very experienced working with physics systems. Pretty much every tutorial, example etc. under the sun for
any physics simulation says something along the lines of
"Changing the timestep of your physics simulation can result in unintented behaviors", which seems to be what you're encountering! 😂
As for your low FPS issues, lets split this into two parts:
1) Your physics logic appears to be frame-rate dependent, which is not what you expected
2) You get low FPS when playing on less powerful devices.
Both of these are going to be quite tricky to figure out. I can suggest some things you may want to look for and some fairly brute-force debugging methods. So:
Physics Sim inconsistency:
I think you're on the right track, making sure that your forces are all being applied in the Fixedupdate and not in the regular update. Check forces being applied as a response to input too! Also make sure that the logic you carry out in the fixedupdate is as minimal as possible. You really don't want to be coding in here unless its absolutely necessary. Don't do any input processing, calculations etc. as that should all be done in the regular update tick. Basically you just want to be applying forces and not really much else.
As for debugging, I would suggest doing something incredibly destructive to try and pinpoint your problem (I do this all the time, both personally and professionally so don't worry about it seeming a bit sketchy). Try commenting out everything in your fixed update except for a very basic physics instruction (e.g Apply a force based on the Fwd vector). Now run the game on the low-power device. If the frame rate is low, are the physics still behaving as you might expect? If so, start uncommenting things bit by bit and try again, see where the issue occurs!
However, if the issue
does occur, then it means that the problem is elsewhere (likely due to things stemming from non fixedupdate methods). Just do the same there, comment everything out and re-enable it bit by bit. See what is screwing you over.
Low FPS on less power devices
Annoyingly, this could be due to many things. The first thing I always tell people to check (because Unity is NOTORIOUS for this) is GC Allocations (Garbage Collection). After that, check for OnGUI related calls. If you have any of those, get rid of them because they're awful and end up making a ridiculous amount of uneccessary draw-calls. Use a plug-in UI solution instead. Finally, comment out all your debug logs. These can absolutely tank the framerate!
After that, we're going to have to run this through a profiler. Have a read over this link to get familiar with how the profiler works, it can be a little confusing but essentially it will tell you where all the time is being spent during processing of a tick.
docs.unity3d.com
Here's an example of what mine looks like:
There's a lot to take in here so here are some tips:
- Under "CPU Usage", you can click the coloured icons to turn on/off their display int he grpah (e.g in my case I dont care about Global Illumiation, UI etc. So I' m not looking at them)
- Whilst "CPU Usage" is selected, Select the "Heirarchy" view mode just above the details panel. You can then click on a colum to sort based on that.
- Sort by Time ms to find out which methods are taking the longest time to process
- Sort by GC Alloc to find out where all your garbace collection allocations are being made.
- This one can be a bit cryptic. It tells you the function in which they are being made but not the exact line. You'll have to comment out things line by line and then look and see if the number of allocations goes down, if you're unfamiliar with how to spot them. Once you've found them, either give me a shout or google "X METHOD without allocations c#" and you should hopefully find an answer
Hope that helps, let me know how you get on!