This content has been marked as final. Show 4 replies
Here's a rough outline of one customized way to do it:
-- Create the full range of animation for the lever in your 3D authoring program (Max, Maya).
-- In lingo, set the lever model's keyframeplayer.playrate to 0.0 so it doesn't move.
-- use _mouse.mouseloc, onMouseDown and modelsUnderLoc on a frequent interval to detect if you've clicked the lever. check out the help on modelsUnderLoc.
-- if you're mouse-down on the lever, use spriteSpaceToWorldSpace to map the current cursor location to a location in the world.
-- set the lever model's keyframeplayer.currenttime property according to the result of spriteSpaceToWorldSpace... this will set the lever position according to the cursor position.
hope it helps some.
Thanks for that - I was hoping there might be a way that I could 'drag' the model, but hold the bottom of the lever using its pivot point.... but thats as far as i've thought....
If I understand what you're intending, this should be possible with proper use of the 3D rotate command. Models normally rotate arond their center but you should be able to get it to rotate along the X & Z axes using the base as a fixed centre of rotation.
I agree with johnAq. I would advise against attempting to use keyframe animations for the joystick movement, as it won't allow for full free 2-way movement.
In your 3d app, make sure your joystick's pivot point is set at its base, so that it rotates correctly.
To detect clicks on the top of the joystick only, make the top of your joystick a separate model, and parent it to the rest of the joystick. You will then be able to use 'modelsUnderLoc' to detect if the joystick top has been clicked.
When clicked, you need to store the mouse position, then, while the mouse button is still held down, examine the difference between the current mouse position and the stored mouse position. This will give you an H & V value for the offset from where the user intially clicked.
You can then use this H and V value for setting the joystick's rotation values. You'll need to experiment to find which of the joystick model's X Y & Z axis correspond to your mouse's H and V values.
You may find it yields more predictable results if you use variables for your joystick's rotation values, and use the mouse H and V to adjust your rotation variables, *then* apply the rotation variables as absolute rotation values for your model. This will probably make it easier to specify the min and max limits for the joystick movement too.
Hope this helps!