Eggys Games

News Archive

C# Make a Basic Array

Lets say we want to make a basic array with a list of items or weapons etc. Lets put them in an array so we can loop through them when we need too.

Start off by declaring it

//Declare Array
public string[] eggysarray;

Then of course here are the basics to setting it and changing it

void Start () {

        ///Set Array
        eggysarray = new string[] { "this", "is", "an", "array"};

        //Change individual array item
        eggysarray[1] = "isnt";

        //returned "this"
        Debug.Log (eggysarray[0]);

Leave a comment Posted in Game Making Programming by Eggy on

Unity - C# Changing Between Lots of Sprites on One Object

Sometimes in a game you're going to want to have a lot of sprites on one object to make it easier to switch between them all. Lets take my Zombie dying for example, we want a bunch of gore to randomly come out of him, but we don't want to make 30 different little prefabs for each one do we? So lets make an array and make it quick and easier. 

First we make an array. Lets call it Mysprites. 

public Sprite[] Mysprites;

Now we have an array so in our inspector when we drag this code onto a prefab. It will allow us to set an array and drag out sprites onto it. Like so :

Now we have a lot of them ready to change. So on start we can do this :

roll = Random.Range (min, max);

GetComponent<spriterenderer> ().sprite = Mysprites [roll];

As we can see here we have a variable Roll that we run through 2 variables. You just need to declare them as ints of however many sprites youre going to use. 

Then it sets the spriteRenderer to display the sprite that it randomized.

There you have it, you can drag this script onto any object and be able to customize which random sprites it spawns, if you don't want it randomized you can customize it too display whichever sprite in the array you want when needed. Like for guns, ui, and more.

Leave a comment Posted in Game Making Programming by Eggy on

Standing on There Head

For my new zombie game I'm working on I had an interesting dilemma. Do I allow you to jump on a zombies head? this seemed to make things too easy when the zombie couldn't get to you. So what I did was make the zombies move there hands upwards to attack you when on there head. This allows you to still jump on them as long as you are quick. 

We can see the unity flowchart below where his attack animation an change to moving his arms up, it idles and then goes back down and returns to normal moving forwards with the arms out.

Leave a comment Posted in Upcoming Games by Eggy on

Do we actually have freedom of speech?

Apparently we have freedom of speech. We can say whatever we want, especially with todays social media where it's quick and easy to write whatever you want online.

However, heres the thing. You only have freedom of speech as long as no one cares about your opinion.

Once you become in the public eye, or are a celebrity then nearly everything you do or say is put closely under inspection. In fact people will even try dig up things you've said in your past to try discredit you. You have to be real careful about what you put online these days if you think your career can be destroyed because of it.

Some may argue that freedom of speech exists, it's just that their are consquences to what we say. While this is true, I don't think you have freedom of speech if people can get you fired from your job for things you said in your personal life. We see this happening more and more to celebrities. I think it must be extremely silencing to celebrities not to be able to voice there opinions unless they are happy and extremely nice opinions. Basically only "PG" rated opinions.

So remember, if you write something dark, offensive or satire based. Think to yourself. Are people gonna dig this up later and throw it in your face? because they probably will. The irony is that they tell people to change and grow up, yet when people do they still go and use the past against them, making their growing up almost redundant in that persons eyes.

Food for thought in todays social media society. "Whats on your mind" sometimes should stay on your mind.

Leave a comment Posted in Articles by Eggy on