I am firing a projectile, on hitting an object it should explode and dmg all the objects within a radius.
For this I am using a separate PhysicsScene. The physics within this scene are simulated each update. So when the projectile collides with a player or the map it will trigger the code underneath. I have tested what the scene is of the object it hits and it is the serverScene. But I never get a result from the OverlapsSphere. (another thing… Why does this use a buffer for which I need to instantiate an array with a fixed size instead of returning the collision) I hope someone can help me!
private void OnCollisionEnter(Collision collision)
{
Collider[] hitColliders = new Collider[5];
Debug.Log(collision.gameObject.scene.name);
int test = WorldController.serverScene.GetPhysicsScene().OverlapSphere(transform.position, 1000, hitColliders, default, default);
Debug.Log(test.ToString());
int i = 0;
while (i < hitColliders.Length)
{
if (hitColliders *== null)*
{
break;
}
Debug.Log("Collide + " + hitColliders*.gameObject.name);*
ReferenceScript script = hitColliders*.GetComponent();*
if (script != null)
{
script.controller.Damage(50);
}
i++;
}
networkObject.Destroy();
}