Problems in setting Cursor like movement
by gigaslime · in Torque Game Builder · 07/31/2008 (1:24 am) · 6 replies
Hi, I am trying to make a game where this object will be placed where my cursor is even when the camera is moving, but its giving me some problems.
I tried the function onMouseMove() but the object wont follow the cursor when the camera moves and mouse doesn't.
Does anybody have a clue to solve this issue?
thank you
I tried the function onMouseMove() but the object wont follow the cursor when the camera moves and mouse doesn't.
Does anybody have a clue to solve this issue?
thank you
#2
I think its something like onSceneUpdate for every frame, not got the docs on this laptop so don't quote me on that. OnUpdate will probably be enough though depending on what exactly you're trying to accomplish.
07/31/2008 (9:00 am)
OnUpdate is every 32ms (tick)I think its something like onSceneUpdate for every frame, not got the docs on this laptop so don't quote me on that. OnUpdate will probably be enough though depending on what exactly you're trying to accomplish.
#3
I tried to use OnUpdate but I don't know how to get the cursor values. I created a global value in onMouseMove to save the value of the cursor and use it in OnUpdate but didn't work.
Is there any function or a way to get the cursor values?
07/31/2008 (3:39 pm)
Thank you James Ford and Craig Fortune.I tried to use OnUpdate but I don't know how to get the cursor values. I created a global value in onMouseMove to save the value of the cursor and use it in OnUpdate but didn't work.
Is there any function or a way to get the cursor values?
#4
Off the top of my head I'm recalling something simple like Canvas.getCursorPos(); Alas I think this'll give you the position of the cursor in pixels, so you'll need to check the resolution you're in etc and convert it all to world co-ords by offsetting it against the camera position... Hardly elegant however.
07/31/2008 (3:55 pm)
Well simply updating a global during an onMouseMove event is going to give you exactly the same issue as before.Off the top of my head I'm recalling something simple like Canvas.getCursorPos(); Alas I think this'll give you the position of the cursor in pixels, so you'll need to check the resolution you're in etc and convert it all to world co-ords by offsetting it against the camera position... Hardly elegant however.
#6
07/31/2008 (4:56 pm)
Cool and no probs ;)
Associate James Ford
Sickhead Games
I guess the problem is there isn't a callback for that time when the camera has moved, so you don't have a good opertunity to know when you need to recalculate the world position for the object based on the camera and cursor position.
Maybe just recalculate it all the time? Use onUpdate or onFrame or whatever that callback that happens every frame is called...