[BUG] SpawnEffect at Vector3.zero in Use MeleeWeapon

echtnice

Member
UCC: from Jan to today,
Unity: 2020.x.x

If the ItemAbility Meleee wants to create an effect on non-convex mesh, it is created at Vectr3.zero.


Notes: For colliders that overlap the sphere at the start of the sweep, RaycastHit.normal is set opposite to the direction of the sweep, RaycastHit.distance is set to zero, and the zero vector gets returned in RaycastHit.point. You might want to check whether this is the case in your particular query and perform additional queries to refine the result. Passing a zero radius results in undefined output and doesn't always behave the same as Physics.Raycast.

Solution MeleeWeapon line 820:

Code:
//HACK 13.01.2021
if (raycastHit.point == Vector3.zero) {
                raycastHit.point = raycastHit.collider.ClosestPoint(hitbox.GameObject.transform.position);
                if (m_RequireInAirMeleeAbilityInAir)
                    raycastHit.normal = m_CharacterLocomotion.Up; //TODO: try to find a better solution
}
//HACK
SurfaceManager.SpawnEffect(raycastHit, hitCollider, surfaceImpact, m_CharacterLocomotion.GravityDirection, m_CharacterLocomotion.TimeScale, hitbox.GameObject);

Maybe some of this can be carried over in the next updates.

Unfortunately I still have no idea how I should fix Normal except when I use Propery m_OverrideNormal with m_Transform.TransformPoint () method and set it in MeleeWeapon. Unfortunately, it's not that elegant.
 
Top