Day 4 : December 7, 2020

Objects to Shooting

Karissa Huynh
2 min readDec 10, 2020

In a world of prefabs and instantiations, I have learned to create Capsule game object into mini laser beams. How? We create a laser object in Project view under the prefab folder and passed that in to the inspector-Player(script)- laserPrefab (which we created is our script). This way our script has a reference + holder for that object… so now it can be instantiated. My player was able to spawn multiple little pellets when ever I hit the space bar.

But its called laser for a reason, so what did we do? We shoot! How? Well we used the same concepts when creating our player (such as: transform.Translate) and repositioning the laser object to move up. Some details we included was the rate to which the laser moved, the boundaries (when the laser moved off screen it will destroy itself.

I was also fascinated with the many efficient ways to code in C#. For example, if you look below we can we my code. It did what it had to do but it was harder to understand & longer (yuck). While the 2nd example is easier to understand and overall more pleasant.

My version when setting laser position offset
The efficient way

It was a productive day. Ready for the next!

Karissa.

--

--

No responses yet