Eli Deeth Blog 5

GAM111

Week 6

This week i continued working on my katamari-like game. I focused on two main parts, the ball Growth with a visual representation and power ups the user can interact with.

The work i added this week was 2 power ups, a magnet power up which used a toggle trigger system and a score modifier pick up. The other thing i worked on was a script that would convert my ball size into a meter and centimeter values. These new values would be returned to the HUD and displayed for the user to visually see. I also fixed the ball so that it wouldn’t grow “legs” and would try and stay round. The only problem i encounter was calculating the centimeter value when the ball was bigger then a meter.

The first thing i worked on was the size to a centimeter, and meter value. This was the first thing i think i have ever done that required me to do a bit of math in my code to get the output i wanted. The first part was easy, setting the centimeter value to equal the current size if the current size was under 100. The problem started when the ball got a bigger then 100. As i am new to coding and couldn’t find a way to get the last two digits from a three digit number i had to use an equation instead. This equation would find out how many times you could divide the current size by 100 then set that number to equal the meter value. it would then divide the current value from the meter value to give the centimeter value.

public class UI_Size : MonoBehaviour
{
int currentsize;
int v;
int m;
int cm;
void Update () {
if (currentsize < 100)
{
cm = currentsize;
}
else if (currentsize >= 100)
{
v = currentsize;
v /= 100;
Mathf.Round(v);
m = v;
v *= 100;
cm = currentsize – v;
}}
}

The next day i worked on ball size control. I did this by adding a trigger on the player which wouldn’t detect the player, which would grow as the player grew and would only let objects connect with the player if they were inside this trigger keeping the ball round.

The last thing i worked on was power ups. Two power up were worked on this week. The score power up was very easy to complete as it was just the a small value added onto the main size controller. The second power up took a lot more code although was still fairly easy to complete. To complete the magnet power up i used three scripts. One that would detect when the magnet object got hit. One that would turn on the triggers attached to the small pickups .And one that would detect if the player was in the trigger and move to him.

My plan for next week is to finish everything i didn’t get completed this as next week is the day when this project will be due.

Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s