No announcement yet.

Mouse targeting

  • Filter
  • Time
  • Show
Clear All
new posts

    Mouse targeting

    Hi again BoneHead, Im back, and I've been wiki-ing quite a bit =)
    I've learned alot, and I've gotten far anoguh to get my HUd working, not I'm left with the Problem; How can I make the mouse interact through the HUD, and with the world beyond, as In clicking on a distant spot, and maing your character move there, or Clicking on an enemy and having your character attack it (maybe using AI aiming logic?) or ctrl+click to target an enemy, make a Ring or target cursor, only visible to the player (cleint side stuff ezer make ^_^)

    Any ideas here? I cant think of anything in the current unrealscript i can relate this to, besides the infamous "double-click move" which ive never seen or heard of anyone using, but I see the function all over the place.

    The Canvas class has a WorldToScreen function which converts vectors in 3d space to a location in 2d space (still a vector, but Z=0) on the HUD, and a function called ScreenToWorld which does the opposite.

    As for control clicking, who knows. Check the wiki for "input" variables, like bDuck (I think it's called) and bWalk. Might not be the right names for the variables (both would be in the PlayerController class, so check there), but they are both input variables. Basically, when you hold the button, its true (or 1, whatever type it is), and otherwise its false (or 0). You can set one of these up (I think) and pass that variable to the HUD as well, with your clicks. Or you can make a struct for which buttons are held (getting into more advanced and clever ways of doing it) and pass that struct. Something like:

    struct ButtonStates
    	var byte bControl;
    	var byte bShift;
    	var byte bAlt;
    It might not need to be bytes, but it needs to be usable by you. Then assemble the struct in the PC and send it to the HUD with the clicks so the HUD knows what buttons are pressed on click. Alternately, you could just check from the HUD to see if the variables are pressed (which involves more casting), or you could pass them all individually, etc. its really up to you.

    If input variables dont work, you can hack the idea in with fancy keybinds and exec functions that toggle bool variables, and OnRelease (check the wiki for this as well) call a function that un-toggles the variable, effectively saying when I press the button, this becomes true, and when I let go this becomes false. Its a little more messy, and a little less elegant, but it gets the job done. Then just bind one of those functions to ctrl, alt, etc. and use that in your HUD.


      clever....ok well i think I got it now


      im prlly gonna get noob-slapped for this, but; What class should this extend?


        You need a combination of classes. You need your own PlayerController, you need your own HUD. You might need more, too. Plus you need new classes for the HUD buttons.