Game Development Community

Top down Mouse Cursor

by Ashley Sidebottom · in Torque 3D Professional · 08/20/2011 (2:01 pm) · 9 replies

Hey,
I have been looking round at the resources to try and find a way of adding a cursor on screen whilst the camera is top down, so that the player turns to face the cursor. The screenshot below shows the game so far.

img804.imageshack.us/img804/4329/bdfarewell.png
The mouse only rotates the player when it is moved left or right, However i am trying to achieve something like the video here: This Video Any help or indication where to start? Cheers.



- Ash

About the author

Student @ University of Huddersfield | Games Designer | sidearse@live.co.uk http://www.sid3bottom.co.uk http://www.bashgames.co.uk


#1
08/20/2011 (3:16 pm)
Have a look at the basic RTS tutorial in the docs, it deals with some of these things.
#2
08/20/2011 (4:30 pm)
Cheers iv had a look at the document and tried to add the necessary things, but there is noting I can see that makes the player face the mouse curser, I add the code, releasing the curser as should, but he does not look at the curser. Could this be to do with the custom camera I have set up?
Cheers again for your help
#3
08/20/2011 (4:53 pm)
I'm trying to do something rather similar. As far as I know, the RTS tutorial is outdated. I've tried using a GuiMouseEventCtrl (and its callback "OnMouseMove()") to handle this but it seems to be broken for the moment (see here). That or I don't know how to use it, which is not excluded.
#4
08/20/2011 (5:12 pm)
Yes threes defiantly something strange going on :S
Looking at your thread it seems to look right, Although im not really a very good programmer
#5
08/20/2011 (7:56 pm)
Hey people, take a look at this resouce, may help.
#6
08/20/2011 (8:56 pm)
i combined a raytrace from the rts tutorial with this resource to get a mouse aiming that also looks up and down (so enemies can be at different heights) as well as turning to face mouse cursor, its with the player not an ai and i hacked it in so its a bit jerky for player movement but the aiming is bang on,

http://www.garagegames.com/community/resources/view/20927

onmouse move send the position / target of the raytrace to the point player at direction function.

i could post what i have but as i say its not perfect....
#7
08/21/2011 (3:57 am)
Thanks Ming I have looked at your code and added it to mine for the Yaw and not the pitch, as I don't need him to look up or down. However i'm unsure where to call the function
serverCmdPointPlayerAt(%client1, %client2.player.position);

I added it in the default binds but this doesn't seem to work, as I suspected. I cant find where the mouse move is located, any more help?
Cheers
#8
09/12/2011 (12:02 pm)
Been playing around with this for a while now. Still had no luck :/
Any other ideas or workarounds?
Cheers
#9
09/12/2011 (8:49 pm)
You would call that by using
commandToServer('PointPlayerAt', %client2.player.position);
but I'm guessing that it should work from the bound callback. The thing I'm not certain of is if that callback is client side or server side - the reason I'm guessing it will work that way is that you say it's not working when you call the raw function.

You should also probably echo(" -- "@%client1@" -- "@%client2); somewhere inside your serverCmdPointPlayerAt() function to make sure that both of those actually have a value when the function is called....

I would consider just passing in %client2 and grabbing the position off of it inside the function, but that's just me.