Ejemplo n.º 1
0
FHitResult APlayerControl::TraceAgainst( UPrimitiveComponent* component, const FVector2D& ScreenPosition )
{
  Ray ray;
	if( !UGameplayStatics::DeprojectScreenToWorld( this, ScreenPosition, ray.start, ray.dir ) )
	{
    error( FS( "Could not DeprojectScreenToWorld (%f %f)", ScreenPosition.X, ScreenPosition.Y ) );
  }
  ray.SetLen( RayLength );
  
  return TraceAgainst( component, ray );
}
Ejemplo n.º 2
0
vector<AGameObject*> APlayerControl::RayPickMulti( const FVector2D& ScreenPosition, SetAGameObject AcceptedTypes, SetAGameObject NotTypes )
{
  TArray<FHitResult> hits;
  Ray ray;
	if( !UGameplayStatics::DeprojectScreenToWorld( this, ScreenPosition, ray.start, ray.dir ) )
	{
    error( FS( "Could not DeprojectScreenToWorld (%f %f)", ScreenPosition.X, ScreenPosition.Y ) );
	}
  ray.SetLen( RayLength );
  return RayPickMulti( ray, AcceptedTypes, NotTypes );
}
Ejemplo n.º 3
0
FHitResult APlayerControl::TraceAgainst( AActor* actor, const FVector2D& ScreenPosition )
{
  FHitResult hit;
  Ray ray;
  // Get the origin & direction of a ray that corresponds with ScreenPosition according to the sceneview.
  if( !UGameplayStatics::DeprojectScreenToWorld( this, ScreenPosition, ray.start, ray.dir ) )
  {
    error( FS( "Could not DeprojectScreenToWorld(%f %f)", ScreenPosition.X, ScreenPosition.Y ) );
  }
  ray.SetLen( RayLength );
  
  return TraceAgainst( actor, ray );
}
Ejemplo n.º 4
0
vector<Ray> APlayerControl::GetFrustumRays( const FBox2DU& box )
{
  vector<FVector2D> pts = { box.TL(), box.BL(), box.BR(), box.TR() };
  vector<Ray> rays;
  // get the 4 rays of the frustum
  for( int i = 0; i < pts.size(); i++ )
  {
    Ray ray;
	  if( !UGameplayStatics::DeprojectScreenToWorld( this, pts[i], ray.start, ray.dir ) )
	  {
      error( FS( "Could not DeprojectScreenToWorld to world for %f %f", pts[i].X, pts[i].Y ) );
    }

    ray.SetLen( RayLength );  // WATCH THIS NUMBER IS NOT TOO LARGE, 1e5f causes imprecision
    rays.push_back( ray );
  }
  return rays;
}