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 sharben · Apr 19, 2014 at 01:25 PM · unity-android

C# Instantiate not working after build "Android"

Hi everyone I'm making a small 2D game for mobile devices and i'm encountering a problem

I did search the forums for a solution to this I found out that others had the similar problem but I didn't find a solution.

What I want to do is when I kill a enemy, the enemy will drop (1) Coin. The code that i'm using works great on unity editor, but after I build it for Android, the enemies just wont die and drop the coin.

The problem is that with InstantiateCoin(); - Enemies won't even die. Without the code InstantiateCoin(); - Enemies die but of course Coin wont drop that way.

Any suggestions for another solution would be appreciated!

Thanks.

--- the code ---

 public void Hit(int _damage)
     {
         //Instantiate hit FX
         Instantiate(hitFX,transform.position,Quaternion.identity);
         //Remove the damage value from the health
         hp -= _damage;
         //If health is less than 0
         if (hp <= 0)
         {
         
             //Instantiate hit FX
             Instantiate(hitFX,transform.position,Quaternion.identity);
             //Instantiate dead FX
             Instantiate(dead,transform.position,Quaternion.identity);
             //Spawn Coin
             InstantiateCoin();
             //Destroy
             Destroy(gameObject);
 
 
         }
     }
 
     void InstantiateCoin()
     {
 
             //Spawn enemy
             Instantiate(Coin,transform.position,transform.rotation);
 
     }


 
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 AdityaViaxor · Sep 25, 2018 at 04:45 AM 0
Share

Hello,

What this line instantiate?

Instantiate(hitFX,transform.position,Quaternion.identity);

why hitFX instantiated twice??

what this line instantiate?

Instantiate(dead,transform.position,Quaternion.identity);

what collider you used.2d or 3d box or spear does it contain rigidbody ??

Instantiate(Coin,transform.position,transform.rotation);

what is the transform position.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Flarvain · Sep 25, 2018 at 03:31 AM

This is an old one but i'm getting the same issue at the moment, has anyone got a solution for this?

I have a public prefab and it spawns perfectly in the editor (i have 0 errors in my code that are displaying) yet simple doesn't spawn for android.

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 SamohtVII · Sep 25, 2018 at 04:44 AM

Try in the "Quality Settings" tab. The player runs with High settings and Android will run with low settings. Make sure you are running low settings in the editor also to match what you see on Android. Not sure if this will help but worth a shot.

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

23 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

Related Questions

Unity Android: Change ForwardNativeEventsToDalvik From Code 0 Answers

Can compute shader run on Android device? 2 Answers

How to add advertisments to unity 3d games (android) 0 Answers

What is best camera position for Android device.? 0 Answers

Android Native Plugin Stopped Working in 4.3 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