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 Bthind101 · Mar 06, 2019 at 09:38 AM · collidervariablecoroutinetransitioncondition

Picking up an object to allow power-up, using external script

I have been searching for a while now, to find out how to make my player transition to a flying mode when picking up an object. This flying mode came with an asset, but unfortunately I cant find a way to transition through the use of the object. In the PowerUp script I want the transition to be for 10 seconds and I realise that Couritine is needed for this, but I want to find out how to the transition first.

Here is the simple PowerUp script:

alt text

and here is what i believe to be the relevant part of the flying script: alt text I would greatly appreciate help, because I am new to C#, thanks.

capture.png (26.4 kB)
capture1.png (56.2 kB)
Comment
Add comment · Show 2
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 dan_wipf · Mar 06, 2019 at 11:45 AM 0
Share

well it looks like it should work, or am i wrong? if you use a collider and tick the trigger toggle, add the pickupscript to the object and the flyscfipt to the player=> must be taged as player then it should work

avatar image Bthind101 dan_wipf · Mar 07, 2019 at 09:03 AM 0
Share

@dan_wipf Thats what I thought as well, but it does nothing. The player doesnt levitate as he usually does when he flies.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Saiguru · Mar 07, 2019 at 12:33 PM

If I am understanding correctly, the player needs to pick up an object and when the player picks up, you need the player to fly and you need the transition from the normal state to flying state to be 10 seconds?

If so, your current code does not work because of the Update Method in the flying script, as it is still checking for the input.

Comment
Add comment · Show 2 · 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 Bthind101 · Mar 09, 2019 at 01:58 AM 0
Share

@Saiguru Yes your are correct about the pick up effect. What would you suggest I change my Update method to? Sorry I am new to C#

avatar image Saiguru Bthind101 · Mar 14, 2019 at 06:13 AM 0
Share

Hi, the issue is the Update method and it checks input each frame, currently even if the player picks up the object from the Update method I still interpret that the Player has to press the "flyButton" and once that is checked the state changes whether to fly or not. So can you try moving the current if (fly){} else{} block outside the current if(Input.GetButtonDown(flyButton)) and try setting the boolean value for fly in the PowerUp script by creating an object.

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

141 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

coroutines : trouble editing and accessing the same public variable 4 Answers

4.6 C# change canvas dependent on value 0 Answers

How to make the Colour parameter in coroutine work with any anything with a colour variable. 2 Answers

After building move doesnt move 1 Answer

Can I use a raycast to retrieve information from the collider? 2 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