3D Play Button

Greetings,

I am new to Unity and I am attempting to make my first User Interface (UI) with 3D objects that I modeled in 3D Studio Max and imported into the editor as FBX files. At the moment I have a background image in and my 3D Play button in place as well. Now, I am looking to get the Play button to react to my Left Mouse Click (only when my cursor is on the button itself, however), and I am trying to get it to rotate 180 degrees in reaction to the click.

I have used JavaScript so far and I can’t seem to get it to work. I’ve also checked out a lot of tutorials and the scripting references, but, as I said, I’m relatively new to Unity and I can’t quite find the code to do what I am looking for. I thought that, perhaps, one could offer some help with this matter.

Thank you for your time.

I think it would be best to perform a ray cast to see if the mouse has clicked the play button(tag the button as “play” or something similar). Use an if statement to return a boolean as true if it hit the play button. Attach a script to the play button and if the boolean is true then transform.rotate the button 180.

Sorry I don’t know Javascript so can’t write up any decent scripts for you

I appreciate your feedback and I will certainly give it a shot right now. Thank you very much! I’ll post how it goes after I mess with it for a while.

You can do them with animated states saved out of max.
Example: http://www.youtube.com/watch?v=yMtNf_qvbWU&feature=related
They reference Itween, wich is kinda useful.

Have you read that?

I’ll check that out, too. Much obliged.

Your welcome. Yeah that would be cool thanks :slight_smile:

Ahh I miss read that you didn’t want it to click. Yeah JRavey is correct with the MouseOver() function. Intead of the ray cast just use OnMouseOver() to check if it’s over the button and if so set the boolean to true. Just make sure you have a script on the button to rotate when the boolean is true and it should work

Awesome, I wasn’t sure if the MouseDown would apply even if I wasn’t on the button, but I’m messing around with it now and I think I’m making some progress on it thanks to all of the input.

Yes, OnMouseDown will apply well here, but make sure you have a collider.

Cool. Btw, nice avatar. I like it. :slight_smile:

Thank you kindly, I’ve got a mesh collider on there now, so I’m working on the rotation and click-ability. The avatar is from the Flash version of the game I’m trying to make this menu for, so hopefully it comes to fruition soon enough. :slight_smile:

Got it! Thank you all for your help. It ended up doing what I needed with the following:

function OnMouseDown()
{
transform.Rotate(0,180,0);
}

Thanks again everyone!