Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by ilPrinny · Oct 28, 2019 at 02:16 AM · tilesskills

Object does not work properly unless I select it in the inspector first?

I have been unable to get any help with this bug anywhere so I thought to ask here so my problem: I have a mono Behavior that listens for a few unity events, when it gets one it checks some conditions then runs a function from another script. The Bug? well when I hit play mode the script only does some of what it is supposed to, it wont affect variables or show debug messages, but it will invoke events and run other functions. It works PERFECTLY if while the game is playing I select the object holding this script I have:

  • Reset unity

  • Reset my computer

  • Updated Unity

  • Re imported all assets

  • Undid most changes in Github

  • Deleted the object and remade it

Nothing worked, I am at my limit and do not want to have to start from scratch because of something I do not know how to prevent. I am new to unity events so I do not know if that is what is causing the Errors

This is some of the code.. Dont know if this will help as what fixes the Error is in the inspector

 //Is called via a event listener when a tile is hovered
 private void Targetting(Tile tile)
     {
         if (selectedSkill != null)
         {
             if (Input.GetMouseButtonDown(0))
             {
                 if (selectedUnit == null) { selectedSkill = null; return; }
 
                 //This check is for testing Im still kinda early on
                 if (selectedUnit.skills[0] != null) { SelectSkill(selectedUnit.skills[0]);}
 
                 if (playerSide.GetTile(selectedTile.x, selectedTile.y) != selectedTile)
                 {
                     selectedSkill.UseSkill(selectedTile, selectedUnit);
                 }
             }
         }
     }
 
 
 //The Skills Use skill function
     public void UseSkill(Tile tile, Unit user)
     {
         if (usesLeft > 0)
         {
             List<Unit> targets = data.targetting.GetTargets(tile);
 
             int dmg;
             int targetsFound = 0;
 
             foreach (var t in targets)
             {
                 if (t != null)
                 {
                     targetsFound++;
                     //HitChances go Here
                     dmg = data.CalculateDamage(user, t);
                     t.HP -= dmg;
                     Debug.Log( t.Name + " took " + dmg + " damage");
                 }
             }
 
             if (targetsFound == 0) { Debug.Log("No Targets"); return; }
             
             CombatEvents.skillUsed.Invoke(this);
             usesLeft--;
         }
         else
         {
             Debug.Log(user.Name + "'s " + data.name + " is out of uses");
         }
     }














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 AshWB · Nov 28, 2021 at 03:00 PM 0
Share

Hi, did anyone in this thread find a solution to their issues, I'm running into the same problem and have no idea how to fix it?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mrasif · May 01, 2020 at 05:26 AM

I am having this same issue, any idea what the issue was?

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 gonzo98x · Jun 10, 2020 at 01:40 AM

I am encountering the same issue. Highlight item in hierarchy, script works. Select anything else or nothing at all and scripts return NRE

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

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

A good 2D tile map editor that works with Unity? 1 Answer

How can I add script to a single tile ? 3 Answers

Make a 2D tile take up more than 1 grid cell 0 Answers

Help developing script for tile generation 0 Answers

Best resources for top down environment tile creation? 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