HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Mouse position?  (Read 2847 times)

sephiroth8888

  • General Accounts
  • *
  • Posts: 2
    • View Profile
[Resolved] Mouse position?
« on: Mar 30, 11, 03:05:30 AM »

Hi everyone,

How can I capture position of mouse cursor (on server side)? I tweak _FxSystemClassMethods a little so I can shoot a projectile (Fx) from the avatar to the mouse position. I tried getMousePosition() but it did not return what I expected, I got a Vector3 with z = 0. You guys have any idea to get this done? ;D
« Last Edit: Nov 02, 12, 09:31:49 PM by HE-Cooper »
Logged

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Mouse position?
« Reply #1 on: Mar 30, 11, 11:15:45 AM »

I could be wrong, but I don't think the server has the client's mouse position.  There is a circle based selector on HJ that can select an area using the mouse and it might help to figure out how to get that information from the client to the server and extrapolate the information into real space.
Logged
Co-Owner/Programmer - The Repopulation

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Mouse position?
« Reply #2 on: Mar 30, 11, 04:27:38 PM »

Are you trying to get the coordinates of the mouse in 2D, or a position in 3D space underneath the mouse?  GetMousePosition() works (on the client, obviously since all I/O is client-specific) for the first one: the x and y of it are the coordinates in the viewport of the mouse cursor, where the upper-left is (0,0) and the lower-right is (xRes-1, yRes-1).  The z of that vector is always 0 and has no meaning.

When you click on a 3D object, you can get that noderef and, thus, its position, but that will not necessarily be exactly where you clicked. To be more exact about it, you may need to do a ray-cast out from the point clicked.  We used to work in another engine that did that, though I believe it was in-engine, not in the scripts. I don't know if Hero has that capability available built-in.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Mouse position?
« Reply #3 on: Mar 30, 11, 06:37:27 PM »

Code: [Select]
method HE_HeroicOnMouseClick(lmb as Boolean, rmb as Boolean, mmb as Boolean, mb4 as Boolean, mb5 as Boolean) as Boolean
// hack for gdc 2008 pathfinding demo 

  if lmb = true
    if $KeyCapture.isSelectGroundUnderMouseModeEnabled()
      intercept as Vector3
      nodeUnder as NodeRef
      GetGroundUnderMouse( intercept, nodeUnder )
   
       call server %INPUT.ReceiveHeroicMouseEventGroundUnderMouse( lmb, rmb, mmb, mb4, mb5, intercept, nodeUnder )
    .
  .
 
  return false
.

Found that in HJInputHandlerClassMethods.  If that is still working it should get the ground under the mouse and then you can send the info back up to the server. 
Logged
Co-Owner/Programmer - The Repopulation

sephiroth8888

  • General Accounts
  • *
  • Posts: 2
    • View Profile
Re: Mouse position?
« Reply #4 on: Mar 30, 11, 09:02:59 PM »

Are you trying to get the coordinates of the mouse in 2D, or a position in 3D space underneath the mouse?

I want to get mouse position in 3D space

Code: [Select]
method HE_HeroicOnMouseClick(lmb as Boolean, rmb as Boolean, mmb as Boolean, mb4 as Boolean, mb5 as Boolean) as Boolean
// hack for gdc 2008 pathfinding demo 

  if lmb = true
    if $KeyCapture.isSelectGroundUnderMouseModeEnabled()
      intercept as Vector3
      nodeUnder as NodeRef
      GetGroundUnderMouse( intercept, nodeUnder )
   
       call server %INPUT.ReceiveHeroicMouseEventGroundUnderMouse( lmb, rmb, mmb, mb4, mb5, intercept, nodeUnder )
    .
  .
 
  return false
.
Found that in HJInputHandlerClassMethods.  If that is still working it should get the ground under the mouse and then you can send the info back up to the server. 

This is exactly what I'm looking for. Thank you very much. It should be working now.

Cheers
« Last Edit: Mar 30, 11, 09:14:14 PM by sephiroth8888 »
Logged