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 IamTabu316 · Sep 07, 2014 at 06:29 PM · powerup

How do I make a power up?

Hey guys i'm making a 2d game and i want to make a power up where it makes a new 2d character. My script doesn't work.

 var OnCollisionEnter();
 {
 if(OnCollisionEnter is Collider create new 2dCharacter);
 }
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by superluigi · Sep 07, 2014 at 09:09 PM

Iam Tabu316 if you don't know how to code you need to learn that first. Once it clicks everything gets easier. Here's an easy way though. Make a collider trigger and when your character enters the collider have it become the new powered up character. That's honestly how everybody would probably do it, by using triggers.

 function OnTriggerEnter(other : Collider)
 {
      if(other.tag == "PowerUp")
      {
           //However you wanna handle it. You can create a new powered up character and destroy the old one, but I personally wouldn't handle it that way. I would just have one copy of each and disable/enable the one that's currently active
      }
 
 }

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 IamTabu316 · Sep 11, 2014 at 02:20 PM 0
Share

I get what the script is doing but the way I want to handle it is to make a new player

avatar image
0

Answer by TimBur · Sep 07, 2014 at 07:13 PM

Your scripting syntax is mixed up in several ways.

First, I think that if you back up a bit, and do a couple tutorials on scripting basics, you'd learn how to avoid some common mistakes, and then be able to do what you want to do faster. At least, that's what I did, and it worked well for me. For example, the Roll-a-ball tutorial (here) shows how to create a pickup, and creating a pickup is the first part of creating a powerup.

Second, when using standard utility functions like OnCollisionEnter, I suggest you begin by copy/pasting the example from the Scripting API help page, and then customizing the code to fit your needs. The example for OnCollisionEnter() is here: http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html

Lastly, I think that a powerup might work better if you gave it a trigger-type collider. You can do this by checking the 'Is Trigger' box in the inspector, and using OnTriggerEnter instead of OnCollisionEnter.

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 IamTabu316 · Sep 07, 2014 at 08:53 PM 0
Share

when I looked at the video you told me to look at, the script didn't work. Every time I look at a script when I collide with my coin, nothing happens.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

driving game power ups 1 Answer

Unity 2D - Yoshi styled "PowerUp"-Creature 1 Answer

Upgrades not applying after first death 2 Answers

Coins Multiplier 0 Answers

HELP! With my Speed power up 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