Don't try to do too much in one if, throw that attack state as a reference somewhere else if you want. So you have a reference to this object now so what you want to do is make sure all your ducks are in a line. I like trig for triggers and col for collision. You can name it something other than 'other'. That 'other' is that other object that triggered said trigger. So you want to check if trigger has been triggered. So pretend I wanted to destroy that object I'd do void OnTriggerEnter(Collider other) Then in start you'd want - rb2d = GetComponent() Īnd then in your on trigger enter the 'other' is the object you hit. Directly below Monobehavior you want to have You can make it global if you would like. If i am trying to grab a Rigidbody2D I'd first make the space for it in memory by creating a variable. You are trying to grab a reference to an object that isn’t set to anything.Try grabbing that component in the start.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |