dark        
Osc blog header photo
Osc's c-blog
Posts 1120Blogs 35Following 0Followers 13


 
 

LONG BLOG

Game In Progress: July 2020

   0

Game in Progress header pic

Another short one. Let's just jump right into it.

Last time, I had questioned whether I could easily write a script that would allow me to randomly generate one of the shape objects I had made. Ths issue was whether I needed to give each object their own script to be able to reference another script that would hold all the logic, or just have that one script that would control everything.

From my, admittedly limited, time researching, it seems like I can work with just the one script. The two main concepts that I'll use are loading resources and instantiating prefabs at runtime. The code for each is short.

Loading resources script

The above documentation shows me info for what's called Resource Folders. This will allow me to reference my assets in the scene without having each shape loaded already. So instead of having all my objects loaded onto the scene/level and hiding them for later use, I can just load them when the game requests it. In this case I would reference my assets at the start of the level, and after the user successfully completes the puzzle to get the next shape.

The next piece of the puzzle is how to actually load the objects onto the scene. Again, another short bit of code.

Instantiate prefabs code

Instantiate(). That's it! Obviously I need to pass some other bits of information, like what object to load, but it's still a very simple piece of code. The great bit about coding is having these pre-built methods and functions that just already do what you need it to do.

So basically what I need to do is look in my resources folders using the code which references the Resources folder for my shape objects. Then randomly determine to load one of them using the Instantiate() function.

My next post will have me actually making the script. This should be easy. But knowing my luck there will be some hiccups. There's always hiccups...

Well, until next time!

Login to vote this up!

LOOK WHO CAME:


Osc   
JuIc3   6
Roager   5


 
 

  0 COMMENTS

Please login (or) make a quick account (free)
to view and post comments.



 Login with Twitter

 Login with Dtoid

Three day old threads are only visible to verified humans - this helps our small community management team stay on top of spam

Sorry for the extra step!

 

About Oscone of us since 9:37 AM on 11.12.2011

Here to play games and make the funnies.
My twitter: https://twitter.com/oscmolo