Closed firegreen closed 6 years ago
Just a heads-up: I'm working on this this morning, because it looks easy to do - Luan is on a plane and won't get back to Paris before 2 days or so.
My latest changes add a Frozen
component, and associated extension methods to GameObject
s.
By just using Se
or being in the Se
namespaces, all GameObjects
are granted to ability to be frozen and de-frozen via extension methods Freeze()
, Defreeze()
and IsFrozen()
.
Behind the hood, these methods just attach or detach a Frozen
component to the GameObject
.
As long as a GameObject
has a Frozen
component, its Rigidbody
is frozen. When the Frozen
component is destroyed, the Rigidbody
is restored.
If we say that all enemy GameObjects have an Enemy
component, then we can freeze them all like so : (untested)
using System.Linq;
// ....
FindObjectsOfType<Enemy>().ForEach(e => e.Freeze());
The FrozenTest
component could be slightly improved to be a general-purpose component that can be attached to any GameObject
, for automatic freezing when pressing some key (possibly using InputActions
for getting the pause button).
Frozen
only freezes Rigibody
components. It should also freeze other kinds of components in the future, such as whatever component is used for animation.
I'll be closing this because it's essentially done now.
Future improvements will only depend on scripts we haven't written yet.
Quoting @yoanlcq in #5:
Freeze entities (a.k.a ZA WARUDO (nobody's ever gonna get this reference))
Required by the pause menu, but also by cinematics. We need to be able to "stop time" for a given set of entities, which means three things:
Every component in Unity has a
SetActive(bool)
method supposed to do exactly that, but we need proof.To find all GameObjects that have a given component, we can use
FindObjectsOfType<MyComponent>()
. This way, we can grab all enemies, then callSetActive(false)
on their RigidBody, animator, etc.The prototype's purpose would be to prove that this actually works because I'm not 100% sure myself.