card rotation ::click & jump+rotate

hi folks!

don't know if i am too stupid or unity is full of bugs. it couldn't be that hard to generate a playcard which jumps up and rotates 180 (lets call this "flip") when clicked...

please show me your shortest scripts of a flipCard-class! still learning...

thnx!

Probably best to use existing animation functions instead of reinventing the wheel. There's AniMate, Tween, and iTween for fancy stuff, and MoveObject for something basic. Using MoveObject, you can do

var moveTime = .5;

function OnMouseDown () {
    MoveObject.use.Translation(transform, Vector3.up, moveTime, MoveType.Time);
    MoveObject.use.Rotation(transform, Vector3.forward * 180.0, moveTime);
}

to make the card move up one unit and flip 180 degrees along the Z axis smoothly over half a second.

if you want to rotate the card instantly it's to simple. attach a collider like box collider to your gameObject of card and create a script in javascript like this.

function OnMouseDown ()
{
   transform.Translate (0,1,0); //moves the card 1 meter up in +y direction 
   transform.Rotate (0,0,180); //rotate 180 degrees around z axis
}

so easy. if you want to do it in several frames so you need to use coroutines. if you need more help or C# code just comment here. unity is the easiest engine that you can use for 3d game development so don't worry

I know this is a very old topic, but I’m having difficulties using Eric’s solution in C#.
I can get it working fine in JS, but no matter what I do, I can’t get it working in C#…

It always says that MoveObject does not exist in the current context.