• 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 raszop · Jun 22, 2017 at 02:10 AM · androidcrashing

game crashing when my character has huge number of hp

hi, im making a roguelike game, and i overcome many, and i mean many problems but this one i can't pass. my game works fine. on my phone it runs in 60 fps, even though all the content is randomly generated and built from small objects. game runs very well until player character has too much hp. i created a test item so i dont die all the time, this item adds 50 000 hp to player character.. and the game randomly crashes when i have so much hp. what could cause it? i've seen games where numbers were in trillions, quadrillions and other custom millions, and this one crashes when my character has 50k hp. what could cause the issue? the amount of hp is stored in an INT variable. maybe this is the issue? i program in C#, and game crashes on android. any of you had similiar problem?

Comment
Add comment · Show 3
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 bobisgod234 · Jun 22, 2017 at 02:20 AM 0
Share

C# int's are huge, 50,000 is a very small number for them.

Do you have any crash logs you can produce?

avatar image tanoshimi · Jun 22, 2017 at 05:30 AM 1
Share

When you say "crash", what actually happens? Does the application exit? With an error message? Or does it "hang" and become unresponsive? Either way, you need to look at the log to found out what happened - it'd be pretty impossible for us to guess what's going wrong without knowing any of your code.

There's nothing special about an int > 50000, so it's likely something in your game logic. Do you have any scripts that use logic based on the score (e.g. an unlockable achievement, or level up) that could have got stuck in an infinite loop? That's the most common cause of crashes.

avatar image raszop · Jul 03, 2017 at 11:21 PM 0
Share

hi, sorry for late reply. i thought thats the case because i couldnt come up with anything else (yeah im stupid). my app has probably problems with memory leaks.. i dont know how to solve them though. when it crashes, there is nothing appearing, it just shuts down. there is no message, nothing. adb logcat only shows that app was killed.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by cstooch · Jun 22, 2017 at 05:46 AM

There is nothing at all wrong with just having a number of 50000. Ints can hold significantly larger numbers. It's impossible for anyone to know why your program is crashing though just from what you've mentioned.

You might need to supply some code, but I'd look at where you set the hp to 50000 and make sure you did that right (I think you'd get a compiler error off the bat if you didn't though, so it's probably fine). Then I'd say you should search all of your project for any references to this value. Somewhere something using this value must be now erroring, for whatever reason. Possibly having more numbers has overflowed some other variable that stores the hp + some text, as an example. It's really not possible for any of us to know with no code, but really the answer to your question is, no of course an int with a value of 50000 shouldn't break your game. But there is obviously something you've done with that variable elsewhere in your code that is the issue.

Failing that, you might need to look into how do some debug logging in Android to trace your steps and figure out where the error is occurring. I'm not familiar with Android enough to know if there's somewhere where errors might be logged or anything like that either.

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 raszop · Jun 22, 2017 at 08:47 AM 0
Share

yeah i guess there's nothing wrong with such numbers but im just out of ideas of what could cause the crashes. the problem is, there is no errors. my game has over 7000 lines of code in scripts and not a single error in console appearing. last time i compiled an .apk it was working stable, but with low framerate. i optimised bunch of things and it works with 60 most of the time but crashes while loading levels. i am so tired of this, textures in my game are 8x8 pixel size and sometimes i still have 10 fps..

avatar image cstooch raszop · Jun 22, 2017 at 01:40 PM 0
Share

Well really, it is easy to search 7000 lines of code.. you don't have to do this by eye. I'm not sure which IDE you use with Unity ($$anonymous$$onoDevelop, Visual Studio, or something else), but they almost all have a "Search in Files" or "Find in Files" or drop down to select "Current Project" or some similar search function that you can search your whole project for this variable. See where you've used it.

Are you certain that if you switch it back to something smaller, it's fine? If so, given it's such a small number (50000 is not a large int), I'm wondering if you've either caused an overflow somewhere (i.e. you're storing more characters in some other variable that was sized too small) or if you've got some other bad logic that's creating a lot of extra loops somewhere, or something. $$anonymous$$ake sure your program runs smoothly if you switch it back to a smaller number. If so, like I said, use the tools in your IDE to search the project for your hp variable and step through, thinking about what might be wrong.

Does this run fine on a PC?

avatar image raszop cstooch · Jul 02, 2017 at 10:43 AM 0
Share

hi, sorry for the late reply but i didnt have access to PC. yes game runs very good on pc, heck it ran good since always. there's just problem with android. i tried everything, my textures are 8x8 pixels.. literally they're 8x8px.. i used occlusion culling, everything and the game crashes.. i dont know what causes the issue, im already tired of it, i tried to update the unity to 5.6 but on 5.6 the loading times are ridicolously long.. i even put the limits on levels size to like the maximum and its still too much to handle.. i think i should start an ad tv app with 1 $$anonymous$$igame, would be lot of easier..

even more, my game has no shadows, no lightning, nothing, just 8x8 textures and i am running it on a snapdragon 820 device with 4gb of ram.. and it crashes..

on fkin pentium pc level loads 2 seconds, on mobile it takes 15 and usually ends up in app hanging itself.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

130 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

Related Questions

Android Game crashing when collecting collectibles 0 Answers

Android game crashes on startup because of Google Play 2 Answers

Game crashing/Force closing in Android Device 0 Answers

How do I prevent Unity Pro crashes for Android projects? 1 Answer

My android game is crashing on stock nexus 4 running Android 5.1.1 . My unity versioin 4.6.7p2 ? Its running on other android devices.I've attached logcat.But i don't understand it.Need urgent help 1 Answer


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