Mouse difficulties
by Brent Chaplin · in Torque Game Engine · 05/28/2005 (9:56 pm) · 3 replies
Hey, I have been trying to understand something for the last week or so and I can't seem to quite get my brain wrapped around it, and I can't find the magic document that really explains it to me. I bought the book, read the EGTGE, filtered through dozens of searches, and tried tracing through the code, and I am full on stuck. I am hopeing someone around here can esplain it to me.
Essentially, what I want to do is design a 3rd Person shooter where the player moves around using only the keyboard, and the mouse is left solely for handling the aiming of the weapon. IE, wherever the mouse cursor is on the screen, that is where the muzzle is pointing. I implemented the Object selection code, and the Advanced camera which sent me well on my way, for the core of this functionality.
I understand that HealthBarHud is the magic GUI in the game where all of the mouse events occur! That's cool, and I understand the dynamic cast to trick the control into thinking it's parents are someone else. I 'Think' I can even get a vector cast from the muzzle of the weapon, to the point where the mouse is clicking or moving in the world. What I can't figure out for the life of me, is how to manually get the weapon to POINT at the mouse cursor and try to destroy it!
My poor little Orc just fires straight ahead. Is he shooting where his head is pointing? Is that what I am to understand? If that is the case can I manually make him look at wherever the cursor is pointing? and the muzzle will follow with some slight changes?
Any help on this would be greatly appreciated!
Also it seems that disabling the mouse in script is not good, as the mouse is solely designed to handle the pitch and yaw and firing of the weapon. Disabling it basically eliminates the entire weapon control system, and what I am trying to do is recover it, and I cant seem to locate the nifty functionality that makes the weapon fire once... I used the Object selection and used the script to increment mvTriggerCount0, but then I just fired away until empty... I ma sure coding a mouseUp event to decrement would solve, but how can I get my hands on that nifty little Mouse0 binding to fire the weapon WITHOUT the mouse enabled (which I need to be able to do object selection and mouse cursor aiming).
Thanks again for any help.
Brent
Essentially, what I want to do is design a 3rd Person shooter where the player moves around using only the keyboard, and the mouse is left solely for handling the aiming of the weapon. IE, wherever the mouse cursor is on the screen, that is where the muzzle is pointing. I implemented the Object selection code, and the Advanced camera which sent me well on my way, for the core of this functionality.
I understand that HealthBarHud is the magic GUI in the game where all of the mouse events occur! That's cool, and I understand the dynamic cast to trick the control into thinking it's parents are someone else. I 'Think' I can even get a vector cast from the muzzle of the weapon, to the point where the mouse is clicking or moving in the world. What I can't figure out for the life of me, is how to manually get the weapon to POINT at the mouse cursor and try to destroy it!
My poor little Orc just fires straight ahead. Is he shooting where his head is pointing? Is that what I am to understand? If that is the case can I manually make him look at wherever the cursor is pointing? and the muzzle will follow with some slight changes?
Any help on this would be greatly appreciated!
Also it seems that disabling the mouse in script is not good, as the mouse is solely designed to handle the pitch and yaw and firing of the weapon. Disabling it basically eliminates the entire weapon control system, and what I am trying to do is recover it, and I cant seem to locate the nifty functionality that makes the weapon fire once... I used the Object selection and used the script to increment mvTriggerCount0, but then I just fired away until empty... I ma sure coding a mouseUp event to decrement would solve, but how can I get my hands on that nifty little Mouse0 binding to fire the weapon WITHOUT the mouse enabled (which I need to be able to do object selection and mouse cursor aiming).
Thanks again for any help.
Brent
#2
I also have been playing around and finally got the mouse world Coordinates to spit out to the Console log every time the mouse moves.... Monsterfies the file in short order, but lets me know its working.
So now I still need some help on how to make the muzzle point point where the cursor is. Also any pointers on getting an object to follow the cursor around would be great so that I can get a nice 3D reticle...
Thanks again!
Brent
05/29/2005 (2:54 pm)
I played around with it some more, and simply added an onMousUp event, which then decrements the mvTriggerCount0. So he is firing properly now, I just think using the Mouse0 would be far more elegant.I also have been playing around and finally got the mouse world Coordinates to spit out to the Console log every time the mouse moves.... Monsterfies the file in short order, but lets me know its working.
So now I still need some help on how to make the muzzle point point where the cursor is. Also any pointers on getting an object to follow the cursor around would be great so that I can get a nice 3D reticle...
Thanks again!
Brent
#3
I also have been playing around and finally got the mouse world Coordinates to spit out to the Console log every time the mouse moves.... Monsterfies the file in short order, but lets me know its working.
So now I still need some help on how to make the muzzle point point where the cursor is. Also any pointers on getting an object to follow the cursor around would be great so that I can get a nice 3D reticle...
Thanks again!
Brent
05/29/2005 (3:27 pm)
I played around with it some more, and simply added an onMousUp event, which then decrements the mvTriggerCount0. So he is firing properly now, I just think using the Mouse0 would be far more elegant.I also have been playing around and finally got the mouse world Coordinates to spit out to the Console log every time the mouse moves.... Monsterfies the file in short order, but lets me know its working.
So now I still need some help on how to make the muzzle point point where the cursor is. Also any pointers on getting an object to follow the cursor around would be great so that I can get a nice 3D reticle...
Thanks again!
Brent
Torque Owner Robert Pierce
Robert