Freeze Effect C#

How would I go about scripting a freeze effect on an enemy.
For example, raycasting a spell and hitting an enemy then applying the effect.

Or something like Dead Space with the stasis field.

I’m setting up a trigger, but what’s the code to use in C# that when the enemy enters they stop moving?
And then obviously after a certain time via float, I imagine it’s just re-enabling whatever I turned off.

I can supply my code but for now a generic solution would be greatly appreciated.

Just stop moving it. A GameObject does not move unless you tell it too. So stop telling it to move.

If you are using a rigidbody then you can set it to kinematic to tell the physics system to ignore it.

1 Like

I suppose I could also stop playing any animations attached?

Ok, for something more complex, a la Dead Space, how exactly would I go about slowing everything down?

Have a freeze method on everything and just Freeze() it. Or set the timescale down?

Yup! If your enemy has an animator that moves with root motion, this:
animator.speed = 0f;would work.

1 Like