private void GameEvents_OnObjectReset(GameEvents.PhysicsInteractionData data)//change on object reset { Debug.Log("Get To hear?"); // Here we are checking first if we have not dropped the ball, and that the object that what has entered reset world trigger // in this case our ball has a rigidbody and has the take of "Ball". if (!IsComplete && data != null && data.other.tag == "NerfDart")// or data.instigator { Debug.Log("Get To hear"); // We can use the keyword var to hold any sort of data, i.e. a var ourData we could put anythin into it, a bool, a string, an int etc. // The downside is because it can be everything Unity has to assign the most amount of memory it can to accomodate it, so use var's wisely especially. // in big projects. If I didn't want to use a var I could write it as GameEvents.CheckListItemChangedData ourData = new GameEvents.CheckListItemChangedData(); . // For this case we are creating a new instance of the class CheckListItemChangedData and storing it in our var var ourData = new GameEvents.CheckListItemChangedData(); // I then take ourData and get the item variable and assign the instance of this class to it, using the 'this' keyword. ourData.item = this; // From there I can set the previousItemProgress Variable of our data to our current progress in this case it return 1 as we have dropped the ball over the edge. // i.e. from 0 being false, to 1 being true, so the previous item progress was it hadn't been dropped over the edge to now it has been dropped over the edge. Dragons.Remove(data.instigator); ourData.previousItemProgress = GetProgress(); // Since the ball has now gone over the edge we want to se the hasDroppedBall bool to true, so we can't do this function again as the task is complete. // We then tell the game events to invoke the CheckListItemChanged event and pass in our data. // this will take our data and up the tasks completed in the UI. GameEvents.InvokeCheckListItemChanged(ourData); } }
private void OnCollisionEnter(Collision collision) { if (tagsThatPass.CheckAll(collision.gameObject)) { var data = new GameEvents.PhysicsInteractionData(); data.instigator = gameObject; data.other = collision.gameObject; GameEvents.InvokeImportantPhysicsCollision(data); } }