Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by headkit · Apr 23, 2010 at 10:24 AM · flipcard

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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image headkit · Apr 23, 2010 at 02:06 PM 0
Share

o.k. - not that short, please. it should make the card flip and jump smoothly...

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Apr 23, 2010 at 07:09 PM

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.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashkan_gc · Apr 24, 2010 at 05:31 AM 0
Share

i should go to wiki first when i write code. i always wrote these things myself :) you are the unify king eric!

avatar image Eric5h5 · Apr 24, 2010 at 06:26 AM 0
Share

Yep, Unify is good, I've found lots of useful stuff on there.

avatar image headkit · Apr 26, 2010 at 11:49 AM 0
Share

hey, this looks good. especially because i come from AS3 and use lots of Tweeners. thanx!

avatar image
0

Answer by Ashkan_gc · Apr 23, 2010 at 11:59 AM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image headkit · Apr 23, 2010 at 12:59 PM 0
Share

hm, thanks, but no. something smooth would be nicer...

avatar image
0

Answer by Felipetnh · Aug 25, 2014 at 06:34 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Look at target and flip 1 Answer

Mirror flip camera? 4 Answers

how to build a 2d character which can faced 2 directions(left and right), with high performance 1 Answer

How to lock the Z axis so my Enemy just flips on the Y axis 1 Answer

how to flip a sprite using touchpad input 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges