Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Babu234664 · Jul 17, 2014 at 02:00 AM · animationspritemovehide

How to call an sprite animation, hide the main character and show him again in another spot?

Hello guys, I'm having some trouble with my 2D game, here's the deal:

I have 2 elevator's, I need my sprite(which is the main character) to:

  • When my character is in front of the elevator and I press W, it hides the main character and start an animation

  • After a short delay, the sprite re-appears on the other elevator and after the animation of the second elevator finishe's.

And them, the script stops.

I tried a lot of ways but couldn't figure it out how to do it, can you guys help me?

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 sethuraj · Jul 17, 2014 at 03:49 AM 0
Share

Please show ur code till now...

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by yagizpoyraz · Jul 17, 2014 at 07:49 AM

//disable sprite, it will be hidden GameObject.Find("playergameobjectname").GetComponent().enabled = false;

//set tranform position of player to elevator position GameObject.Find("playergameobjectname").transform.position = GameObject.Find("elevator gameobjectname").transform.position;

//now lets make our sprite visible again GameObject.Find("playergameobjectname").GetComponent().enabled = true;

you can use Invoke method if you want to make delay between these actions.

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
avatar image
0

Answer by smallbit · Jul 17, 2014 at 04:07 AM

Hard to tell without seeing your code. But here are the steps for a one way for doing this:

  • when click W disable sprite renderer ( GetComponent().enabled = false;)

  • wait a while for instance calling a method SpawnPlayerInOtherElevator() (i.e. Invoke("SpawnPlayerInOtherElevator",1f);)

  • in SpawnPlayerInOtherElevator(), First move the player to the other elevator position (i.e. transform.position = elevator.transform.position) depends on your player controler setup.

  • enable sprite (GetComponent().enabled = true;)

There are some other issues like you should disable your player controler for the time he is invisible etc. But you will figure this out.

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 Babu234664 · Jul 17, 2014 at 04:14 AM 0
Share

Hey man, thanks for this answer =]

Can you explain that in javascript? (Noob in coding here e.e)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Hide parts of the sprite in 2D? 0 Answers

Animated Overlay Armor Sprite 1 Answer

How do I animate a 2D sprite? 1 Answer

Animation with Transparency Floats Above Ground 1 Answer

Is there a way to abstract sprite from animation clip? 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