The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Class 'instanceof'?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Class 'instanceof'?

    I am having a little trouble figuring out the proper syntax for what I want to do. What I *really want is the equivalent of the 'instanceof' operator in Java.

    What I am trying to do:
    Basically I want to get 'the world' under my mouse, which may be a BSP, height map, static mesh... (basically *not a skeletalmesh).

    I noticed that all Objects have a Class member/reference. However I seem to be having an issue with the syntax... The following code does not compile, and im not exactly sure how to compare classes, or find out if a specific actors class inherits ...

    simulated function GetWorldUnderMouse(out Vector hitLocation, out Actor TraceActor)
    	local Vector hitNormal;
    	foreach TraceActors(class'Actor',TraceActor, hitLocation, hitNormal,  mouse3D + worldDireciton * 5000, mouse3D )
    		if( TraceActor == WorldInfo || TraceActor.Class == StaticMeshActor )
    	TraceActor = none;
    I realize I could accomplish this task by doing three raycasts, on class'Actor' and check for worldinfo (for bsp), on class'StaticMeshActor' and whatever actor a terrain is.. however that seems wasteful.

  • #2
    Actors that are considered to be world geometry have a flag called bWorldGeometry set to true. So you can just filter for that.

    That is to say:

    if (Actor.bWorldGeometry)
      // Trace has hit the world


    • #3
      Thanks, that should work for me, and would most likely be faster doing any class / inheritance checks anyway.

      That being said, for future reference, does anyone know if there is a way to do a class / inheritance check?


      • #4
        In Object.uc:

         * Determine if a class is a child of another class.
         * @return	TRUE if TestClass == ParentClass, or if TestClass is a child of ParentClass; FALSE otherwise, or if either
         *			the value for either parameter is 'None'.
        native(258) static final function bool ClassIsChildOf( class TestClass, class ParentClass );
        native(197) final function bool IsA( name ClassName );