Announcement

Collapse
No announcement yet.

In game mouse selection...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    In game mouse selection...

    Okay...I'm trying to create a certain amount of interactivity into the game, a lot like Unreal ed. I'm using screen to world right now in my code and I seem to be able to display the information about a static mesh. Is there a way to select or display BSPs ingame, like how u can select walls or floors in unrealEd?


    My code thus far....
    Code:
    function userClickET(int whichButton)
    {
         local vector hitLoc, hitNorm, mouseLoc, mouseDir, tStart, tEnd;
         local Actor other;
         local Material hitMat;
    
         if(whichButton ==2)
         {
           //   bMouseRightClick = true;
          //    pOwner.CLientDeselctObject);    //dosen't exist yet ;)
              return;
         }
    
         //A HUD check has to be performed somewhere in the code...
    
         if(bMouseOverHUD)
         {
              //check to see what kind of object has been clicked upon...
         }
    
         mouseLoc.X = cursorX;
         mouseLoc.Y = cursorY;
         mouseDir = ScreenToWorld(mouseLoc, pOwner.Pawn.Location, pOwner.Pawn.Rotation);
         mouseDir = Normal(mouseDir);
    
         Log("mouseLoc =" @mouseLoc@ "     mouseDir (screentoworld=" @mouseDir);
         Log("mouseLoc.X" @mouseLoc.X@ "    mouseLoc.Y" @mouseLoc.Y);
    
    
         tStart = pOwner.Pawn.Location;
         tEnd = tStart + mouseDir * 5000;
         other = pOwner.Trace(hitLoc, hitNorm, tEnd, tStart, true, ,hitMat);  //Need to be optimized...
    
         log("other = (trace run here)" @other);
         log("tStart = (location)" @tStart@ "      tEnd = (tStart + mouseDir * 5000)" @tEnd);
    
    }

    #2
    I'm trying a similar thing using the ScreenToWorld function, and it's so far proving to be very unreliable. I think the cause of it is the vector I'm using.

    Hampster, what range of values does mouseLoc X and Y log out to?

    Comment


      #3
      Here's an example of my typical output:

      Code:
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.LevelInfo0
      ScriptLog: tStart = (location) -124.22,171.98,700.00       tEnd = (tStart + mouseDir * 8000) -4505.76,6864.87,785.21
      ScriptLog: mouseLoc = 171.00,267.00,0.00      mouseDir (screentoworld= 0.12,0.99,0.04
      ScriptLog: mouseLoc.X 171.00     mouseLoc.Y 267.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.StaticMeshActor286
      ScriptLog: tStart = (location) -124.22,171.98,700.00       tEnd = (tStart + mouseDir * 8000) 808.98,8111.83,996.32
      ScriptLog: mouseLoc = 171.00,267.00,0.00      mouseDir (screentoworld= 0.12,0.99,0.04
      ScriptLog: mouseLoc.X 171.00     mouseLoc.Y 267.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.StaticMeshActor286
      ScriptLog: tStart = (location) -124.22,171.98,700.00       tEnd = (tStart + mouseDir * 8000) 808.98,8111.83,996.32
      ScriptLog: mouseLoc = 382.00,262.00,0.00      mouseDir (screentoworld= -0.64,0.77,0.06
      ScriptLog: mouseLoc.X 382.00     mouseLoc.Y 262.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.StaticMeshActor285
      ScriptLog: tStart = (location) -124.22,171.98,700.00       tEnd = (tStart + mouseDir * 8000) -5211.26,6327.43,1182.01
      ScriptLog: mouseLoc = 382.00,262.00,0.00      mouseDir (screentoworld= -0.64,0.77,0.06
      I'm able to get it to detect static mesh actors as you can see, and not bsps. If I click a BSP, it comes up as levelinfo0. Also, i've noticed that the "hit area" for the static meshes seems very small an ddosen't cover the entire object.

      This stuff was clicked from more of a distance away. You'll notice that the screentoworld coords change slightly, but not by much. I can't tell if it's getting those numbers from the world coords or maybe from the static mesh's location in relation to the player. Regardless, the mouseLoc.X and Y look pretty good....

      Code:
      ptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.KIT_CabinetDoors_s26
      ScriptLog: tStart = (location) -13.68,217.73,700.00       tEnd = (tStart + mouseDir * 8000) -7975.91,-105.13,-6.17
      ScriptLog: mouseLoc = 425.00,289.00,0.00      mouseDir (screentoworld= -1.00,-0.04,-0.09
      ScriptLog: mouseLoc.X 425.00     mouseLoc.Y 289.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.KIT_CabinetDoors_s26
      ScriptLog: tStart = (location) -13.68,217.73,700.00       tEnd = (tStart + mouseDir * 8000) -7975.91,-105.13,-6.17
      ScriptLog: mouseLoc = 416.00,262.00,0.00      mouseDir (screentoworld= -1.00,-0.00,0.03
      ScriptLog: mouseLoc.X 416.00     mouseLoc.Y 262.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.LevelInfo0
      ScriptLog: tStart = (location) -13.68,217.73,700.00       tEnd = (tStart + mouseDir * 8000) -8011.08,178.17,900.12
      ScriptLog: mouseLoc = 416.00,262.00,0.00      mouseDir (screentoworld= -1.00,-0.00,0.03
      ScriptLog: mouseLoc.X 416.00     mouseLoc.Y 262.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.LevelInfo0
      ScriptLog: tStart = (location) -13.68,217.73,700.00       tEnd = (tStart + mouseDir * 8000) -8011.08,178.17,900.12
      ScriptLog: mouseLoc = 417.00,245.00,0.00      mouseDir (screentoworld= -1.00,-0.01,0.10
      ScriptLog: mouseLoc.X 417.00     mouseLoc.Y 245.00
      ScriptLog: other = (trace run here) RSC-rscbuild_v121_MissingTextures.KIT_CabinetDoors_s26
      ScriptLog: tStart = (location) -13.68,217.73,700.00       tEnd = (tStart + mouseDir * 8000) -7976.35,125.22,1466.38
      ScriptLog: mouseLoc = 417.00,245.00,0.00      mouseDir (screentoworld= -1.00,-0.01,0.10

      Comment

      Working...
      X