Would it be possible to make a script telling unity to slow down time when a certain object enters a collider?. Fx. lets say i have a collider around my player and when an object named BulletEnemy enters that collider, time slows down to half speed?
Yes. Look up OnTriggerEnter, OnTriggerExit, and Time.timeScale.
OnTriggerEnter is the correct path as @tanoshimi has stated.
For slowdown. I found this handy little advice online. A very kind soul on the internet gave the answer on here
The gist of it is to add these two lines
Time.timeScale = 0.5;
Time.fixedDeltaTime = 0.02F * Time.timeScale;
The fixedDeltaTime is what causes the smoothness to play out. If for whatever reason you need to revert the game back to normal speeds. I apply this after all the calculations are done.
Time.timeScale = 1;
Time.fixedDeltaTime = 0.02F ;
Seems to work for me.
Happy coding and hope this helps others.
Why wouldn’t it be possible?
In your script, however your applying velocity, just reduce it to half if they’re within a certain vicinity of the player.
You’ll most likely want to use an overlapping sphere: Unity - Scripting API: Physics.OverlapSphere