generate combatants here I don't know why there is this inexplicable error, and I learned in 3d case inside the tutorial, the following picture, the component parameters are all default, I don't know why, all combatants are together? Instead of randomly generated within this collision body ......
Could you go into a bit of details on what I'm looking at here? And what you want to do?
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Combatant Spawner Components 【2d】 2d, generated combatants, it does not generate randomly within this collision body, but only at the edges of the collision body
It's the same as the picture inside the link I posted above. The light green one is the collision body
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
and the GetSpawnCenter() method also need to be modified
===============
Although now under 2d it has been randomly generated within the range of the collision body, he will exceed this defined range ...... Although I have modified it to suit my use at the moment, there is still undeniably some problem, and I don't understand the code very well!
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
2d, generated combatants, it does not generate randomly within this collision body, but only at the edges of the collision body
It's the same as the picture inside the link I posted above.
The light green one is the collision body
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Your 2d collision body judgement code uses the 3d code for random values, just change it as follows:
protected virtual Vector3 GetRandomAdd()
{
Vector3 add = Vector3.zero;
if(!this.settings.spawnAtPosition)
{
if(this.usedCollider != null &&
this.usedCollider.enabled)
{
add.x += UnityWrapper.Range(-this.usedCollider.bounds.extents.x,
this.usedCollider.bounds.extents.x);
add.z += UnityWrapper.Range(-this.usedCollider.bounds.extents.z,
this.usedCollider.bounds.extents.z);
}
else if(this.usedCollider2D != null &&
this.usedCollider2D.enabled)
{
add.x += UnityWrapper.Range(-this.usedCollider2D.bounds.extents.x,
this.usedCollider2D.bounds.extents.x);
add.y += UnityWrapper.Range(-this.usedCollider2D.bounds.extents.y,
this.usedCollider2D.bounds.extents.y);
}
}
return add;
}
and the GetSpawnCenter() method also need to be modified
===============
Although now under 2d it has been randomly generated within the range of the collision body, he will exceed this defined range ...... Although I have modified it to suit my use at the moment, there is still undeniably some problem, and I don't understand the code very well!
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!