Hi,
Spawner.cs doesn't pool the instantiate GameOgjects, does it?
I'm trying to add the Opsive Pool system (see here:)
https://opsive.com/support/documentatio ... ject-pool/
But I can't add "using Opsive.UltimateCharacterController.Game;" as Visual Studio says Opsive Namespace was nor found.
Any ideas how can I procedure? I just one to change ObjectPool.Instantiate instead of Instantiate
Thanks.
Poll on Spawner.cs
Re: Poll on Spawner.cs
Hi,
The methods in the Spawner class are virtual so you can override them to use a pooling system. However, there's a patch that makes it even easier by isolating the Instantiate and Destroy calls into separate virtual methods:
Just create a subclass of Spawner that overrides these two methods.
Here is a link to the patch: QM_SpawnerPatch_2019-02-15.unitypackage
The methods in the Spawner class are virtual so you can override them to use a pooling system. However, there's a patch that makes it even easier by isolating the Instantiate and Destroy calls into separate virtual methods:
Code: Select all
/// <summary>
/// Returns an instance of a prefab. Override this method if you want to
/// use a pooling system instead of Instantiate.
/// </summary>
protected virtual GameObject InstantiateEntity(GameObject prefab)
{
return Instantiate<GameObject>(prefab);
}
/// <summary>
/// Destroys an instance of a prefab. Override this method if you want to
/// use a pooling system to return the instance to the pool.
/// </summary>
protected virtual void DestroyEntity(GameObject go)
{
Destroy(go);
}
Here is a link to the patch: QM_SpawnerPatch_2019-02-15.unitypackage
-
- Posts: 178
- Joined: Fri Sep 21, 2018 8:38 pm
Re: Poll on Spawner.cs
Thanks very much!!