@@ -593,7 +593,7 @@ public void FindAndSetBuildingAreaByAxes(Vector2 aimAxes)
593593 public void FindAndSetBuildingAreaByMousePosition ( )
594594 {
595595 Vector3 worldPosition2D ;
596- LoopSetBuildingArea ( physicFunctions . RaycastPickObjects ( CacheGameplayCamera , InputManager . MousePosition ( ) , CurrentGameInstance . GetBuildLayerMask ( ) , 100f , out worldPosition2D ) , worldPosition2D ) ;
596+ LoopSetBuildingArea ( physicFunctions . RaycastPickObjects ( CacheGameplayCamera , InputManager . MousePosition ( ) , CurrentGameInstance . GetBuildLayerMask ( ) , Vector3 . Distance ( CacheGameplayCameraTransform . position , MovementTransform . position ) + ConstructingBuildingEntity . BuildDistance , out worldPosition2D ) , worldPosition2D ) ;
597597 }
598598
599599 /// <summary>
@@ -604,14 +604,15 @@ public void FindAndSetBuildingAreaByMousePosition()
604604 /// <returns></returns>
605605 protected bool LoopSetBuildingArea ( int count , Vector3 raycastPosition )
606606 {
607+ ConstructingBuildingEntity . HitSurface = false ;
607608 IGameEntity gameEntity ;
608609 BuildingArea buildingArea ;
609610 Transform tempTransform ;
610611 Vector3 tempVector3 ;
611612 for ( int tempCounter = 0 ; tempCounter < count ; ++ tempCounter )
612613 {
613614 tempTransform = physicFunctions . GetRaycastTransform ( tempCounter ) ;
614- tempVector3 = GameplayUtils . ClampPosition ( CacheTransform . position , physicFunctions . GetRaycastPoint ( tempCounter ) , ConstructingBuildingEntity . BuildDistance ) ;
615+ tempVector3 = physicFunctions . GetRaycastPoint ( tempCounter ) ;
615616 if ( CurrentGameInstance . DimensionType == DimensionType . Dimension3D )
616617 tempVector3 . y = physicFunctions . GetRaycastPoint ( tempCounter ) . y ;
617618
@@ -623,6 +624,7 @@ protected bool LoopSetBuildingArea(int count, Vector3 raycastPosition)
623624 {
624625 // Hit something and it is not part of constructing building entity, assume that it is ground
625626 ConstructingBuildingEntity . BuildingArea = null ;
627+ ConstructingBuildingEntity . HitSurface = true ;
626628 ConstructingBuildingEntity . Position = GetBuildingPlacePosition ( tempVector3 ) ;
627629 break ;
628630 }
@@ -637,12 +639,14 @@ protected bool LoopSetBuildingArea(int count, Vector3 raycastPosition)
637639 }
638640
639641 ConstructingBuildingEntity . BuildingArea = buildingArea ;
642+ ConstructingBuildingEntity . HitSurface = true ;
640643 ConstructingBuildingEntity . Position = GetBuildingPlacePosition ( tempVector3 ) ;
641644 return true ;
642645 }
643646 if ( CurrentGameInstance . DimensionType == DimensionType . Dimension2D )
644647 {
645648 ConstructingBuildingEntity . BuildingArea = null ;
649+ ConstructingBuildingEntity . HitSurface = false ;
646650 ConstructingBuildingEntity . Position = GetBuildingPlacePosition ( raycastPosition ) ;
647651 }
648652 return false ;
0 commit comments