Bouncing Soccer Ball Game Help...

Hey everyone,

I need a little guidance from the community, or anyone who is willing to help me…I am tearing my hair out here, trying to figure out how to code my game idea. I am a designer who is trying to learn coding (as usual designers are terrible coders). I have done 3 weeks of unity tutorials and I go through them fine, but when I come to figure out writing my own code to implement my ideas, nothing pops into my head, I get confused, and then I break stuff…:stuck_out_tongue:

So far, I have created all the models and title screens and everything loads to the correct scene.

Once Start Session is pressed, it zooms to the pitch and to a 3 sided black box which will have 8 floating balls.(Just using one as test at the minute)
I have added the rigidbody, physics, etc and the balls do bounce around randomly but this is without any coding…


Here’s what I need help or a little guidance on…Instructions appear, and then start session is below the instructions. I need to press start session, the box disappears, then 4 of the balls randomly highlight ( I created a variable called randomLight but that’s it: randomLight.color = Color.blue). Then after 5 seconds, the highlight is removed and the balls begin to randomly bounce around, while you are trying to track the ones which were highlighted. After 20 seconds, all the balls stop, become numbered, and you choose the ones you were tracking. If correct, the next session speeds up, if wrong, it slows down.

After I have this figured out, I want to be able to log results to a graph and have them in the results section of the game to track progress.

I know I am a complete noob but this stuff is seriously confusing me and I refuse to give up! I want to learn how to do this myself but need a little push. I thought I could create a boolean which would define if the answer was correct, then speed up the next session? I commented it out but pasted below is all I have so far (not much! )Thanks for reading everyone!

using UnityEngine;
using System.Collections;

public class bounce : MonoBehaviour {
    public float speed = 1f;
    private Rigidbody rbody;
    //editor settings as test
    public float speedIncrement = 1f;
    public float maximumSpeed = 7f;
    //bool correct;

    // Use this for initialization
    void Start ()
    {
        rbody = GetComponent<Rigidbody>();

    }

    void Update () {

        speed = speed;
        if(speed >= maximumSpeed) speed = maximumSpeed;

        //else if (correct == true) {
            //speed += speedIncrement;
    }

    }

//}

You could create a panel/image in the canvas, with the instructions and a button.

publice GameObject instrucPanel;

//This is for your button to deactivate the instruction panel
public void DeactivateButton(){
instrucPanel.SetActive(false);
}

For this you would need a Coroutine, this delays time for you and then calls a function.

For highlighting the balls you will need an Array to choose all the balls and to set the color you can use this…
gameObject.renderer.material.color = Color.blue;

Again, you can use Coroutine for waiting. For the bouncing, you can use the physics material. Or attach a script to the balls and make them move on the Y axis.