Camera distance or high, how to make it work?
by D Fasel · in Torque 3D Professional · 12/10/2010 (12:12 am) · 0 replies
I try out the following code for make the mouse wheel to set the camera high/or distance. But it just don't work in T3D beta3.
Anyone have a idea what to do that this work, or have a other code to use the camera distance with the mouse wheel?
Here the code from the tutorials:
add in default.bind.cs:
1. // Adjusts the height of the camera using the mouse wheel
2. function mouseZoom(%val)
3. {
4. // If wheel was scrolled forward
5. // move camera closer to the ground
6. if(%val > 0)
7. {
8. commandToServer('adjustCameraHeight', -3);
9. }
10. // If wheel was scrolled back
11. // move camera away from the ground
12. else
13. {
14. commandToServer('adjustCameraHeight', 3);
15. }
16.}
Next, open game/scripts/server/commands.cs. We will add the server command to adjust the camera height at the bottom of the script file:
1. // Server command that adjusts camera height
2. function serverCmdadjustCameraHeight(%client, %adjustment)
3. {
4. // Take the current camera position (a vector)
5. // Then add or subtract from the Z element, based on
6. // the %adjustment value passed in
7. %client.camera.position = VectorAdd(%client.camera.position, "0 0 " @ %adjustment);
8. }
It seems that this not works :
%client.camera.position = VectorAdd(%client.camera.position, "0 0 " @ %adjustment);
Anyone have a idea what to do that this work, or have a other code to use the camera distance with the mouse wheel?
Here the code from the tutorials:
add in default.bind.cs:
1. // Adjusts the height of the camera using the mouse wheel
2. function mouseZoom(%val)
3. {
4. // If wheel was scrolled forward
5. // move camera closer to the ground
6. if(%val > 0)
7. {
8. commandToServer('adjustCameraHeight', -3);
9. }
10. // If wheel was scrolled back
11. // move camera away from the ground
12. else
13. {
14. commandToServer('adjustCameraHeight', 3);
15. }
16.}
Next, open game/scripts/server/commands.cs. We will add the server command to adjust the camera height at the bottom of the script file:
1. // Server command that adjusts camera height
2. function serverCmdadjustCameraHeight(%client, %adjustment)
3. {
4. // Take the current camera position (a vector)
5. // Then add or subtract from the Z element, based on
6. // the %adjustment value passed in
7. %client.camera.position = VectorAdd(%client.camera.position, "0 0 " @ %adjustment);
8. }
It seems that this not works :
%client.camera.position = VectorAdd(%client.camera.position, "0 0 " @ %adjustment);
About the author
Working in the team of Winterleaf Entertainment as an Lead Level Designer and Environmental Artist. Selling content and art packs ready for T3D at my shop www.game3d.ch/shop