Wednesday, October 2, 2019

Rube Goldberg Event...now with scripts!

For this version of the Rube Goldberg event, I imported 2 objects from the unity store: Donuts and plate03. I gave them both mesh colliders and I wanted to use them as stand-ins for the original pink cube and end green cube. The Donuts asset seemed to have a bounce physics already added to the prefab that I was not able to find in the inspecter to change, so I just had to readjust where the original end point was located to compensate.
With the new assets, I wanted to script end the whole event with a particle sparkle when the Donuts collided with the plate03. Unfortunately, I was never able to get to work. I looked up online many ways to fix the issue but was none seemed to trigger the particle effect on collision. You can view my code below.



I then decided to just add a color change effect when the Sphere collides with the dominoPlatform turning it to white. Here I had another issue that the color would not visibly change in the play window but when viewing the video you can see on the right-hand side in the inspector that the color does change to white on collision. I'm not sure what was going wrong there, I even tried taking off the material shader of brown just in case that was overriding the color change, but it would still stay the original color. Code for that below.





The script that did work for me was that at the beginning of the event I added a user input where on pressing of the spacebar would raise my newly created pink wall. Instead of the Sphere falling in from the sky this wall is now blocking the Sphere from starting the event until the user decided to. This wall is frozen on the X & Z axises and in the script, I added a public yPush so that I would be able to change the force of the keystroke while in Unity.


I would like to work more on how to understand what script conponats are available and understanding how they work in a more intuatave way than just googling any issue. Most examples online are able game creation and player modle interaction which I did not find very helpful.

No comments:

Post a Comment