Home Technical Talk

Trouble with MEL script, trying to make UI for ball with gravity dynamic

Hey, I've been struggling with this for the last two days. I am trying to create a game with mel script, not by choice but for a project. The last piece that I need to make this possible is to attach transformation controls to a sphere that has a gravity dynamic (g.d.) on it. However, I think because the sphere has the g.d. on it , that overrides any transformation scripting. I tried breaking the connections of the g.d. on the axis' that I need to move but that afffects the precision of the g.d. , so no good. I have also tried creating another sphere, and attaching the UI buttons to transform that, while parenting the original sphere to it, kinda of works but not great. Originally, I was hoping to use a script similar to the throttle in the "make motor boat" effect. By adjusting the throttle and rudder you can make a boat turn. It is easy to turn this into buttons. However, I can't figure out how to re-script those attributes.

My code is such so far: In order to recreate you would need to create plane with passive rigid body and have a sphere (sphere3) with gravity
//////Ensures script will run if previously ran
if ( `window -exists MyWindow` ) {
deleteUI MyWindow;
}
window -t "melBallMadness V 1.0"
-wh 500 400
-mxb off
-resizeToFitChildren on
-sizeable off
MyWindow;
///////Declaring UI variables
formLayout myForm;
/////Image location
image -image (`internalVar -usd` + "MO/mxp_snowJob/titleImages/mxp_snowJob2.jpg") -w 60 -h 140 titleImage;
text -fn "boldLabelFont" -l "Welcome to melBallMadness press Start to play!" titleText;
/////Starts "Game"
button -l "Start/Pause"
-command "playButtonForward;"
startButton;
/////Resets "Game"
button -l "Reset"
-command "playButtonStart;"
resetButton;
separator -w 400 sepLine;
text -l"Sound" soundText;
////Enables sound on or off
checkBox -l"On/Off"
-onCommand "setSoundDisplay Goldfrapp___Strict_Machine__We_Are_Glitter_Mix_ 1;"
-offCommand "setSoundDisplay `timeControl -q -s $gPlayBackSlider` 0;" checkBox;
///Controls
button -l "Left" -c moveLeft leftButton;
button -l "Right" -c moveRight rightButton;
button -l "Foward" -c moveFoward fowardButton;
button -l "Back" -c moveBack backButton;
global proc moveLeft(){
select -r pSphere3;
move -r 0 0 .1;
}
global proc moveRight(){
select -r pSphere3;
move -r 0 0 -.1;
}
global proc moveFoward(){
select -r pSphere3;
move -r .1 0 0;
}
global proc moveBack(){
select -r pSphere3;
move -r -.1 0 0;
}
/////////////UI Setup -af = attach Form, -ac = attach Control , -ap = attach Position
formLayout -e

-af titleText top 15
-af titleText left 150
-af titleText right 0

-af startButton left 0
-ac startButton top 10 titleText
-ap startButton right 0 50
-af resetButton right 0
-ac resetButton top 10 titleText
-ac resetButton left 1 startButton

-af sepLine left 0
-ac sepLine top 10 startButton
-af sepLine right 0
-af titleImage left 250
-ac titleImage top 10 sepLine
-af titleImage right 275
-af soundText left 0
-ac soundText top 5 backButton
-af soundText right 400
-af checkBox left 0
-af checkBox bottom 0
-af checkBox right 600
-af fowardButton left 195
-ac fowardButton top 20 titleImage
-af fowardButton right 200

-af leftButton left 130
-ac leftButton top 1 fowardButton
-ap leftButton right 0 50
-af rightButton right 130
-ac rightButton top 1 fowardButton
-ac rightButton left 1 startButton
-af backButton left 195
-ac backButton top 1 leftButton
-af backButton right 200
 
 



myForm;
showWindow MyWindow;


I appreciate any insight, thanks!
Sign In or Register to comment.