Roll-a-ball Tutorial Q&A

Unity 5 - Roll a Ball game - 5 of 8: Creating Collectibles - Unity Official Tutorials

Problem:
Material doesn’t apply its self to the prefab i.e. I drag the material onto the prefab object, but it does not apply the material to the other duplicates(pickups)
Also if I try applying material directly onto a pickup and clicking apply, it doesn’t change the rest of the instances when I try to apply. Whats happened?

When I hover over the apply button , I get the warning that "You have broken the prefab connection… " Also “GameObject reference missing”, but this script warning has existed since the tutorial and things seemed to work until now.

There is no problem with the pick ups rotation or ball movement.

!(http://Unity 5 - Roll a Ball game - 5 of 8: Creating Collectibles - Unity Official Tutorials)

can anyone help me , im using microsoft vs here is the code
here is the error
Severity Code Description Project File Line Suppression State
Error ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index Solution ‘ROLL A BALL’ ‎(1 project) /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs 633

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public float speed;

private Rigidbody rb;

void Start ()
{
rb = GetComponent();
}

void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);

Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

rb.AddForce (movement * speed);
}
}

So does the ball continue to move at a steady velocity? or does it move very slowly when you release the movement keys?

the prefab for the pickup that you have in the prefab folder will be used as the template for all the pickups.
so any changed to that will propogate through to all instances of that prefab in the scene.

so dragging that pickup from the prefab folder into the scene will create an instance of that prefab, and will be bound to it.
check your pickup prefab in the prefab folder, you seem to have a missing script in the inspector. so highlight your pickup in the prefab folder and delete the missing script that might be causing some issues.

drag a copy of that prefab into the scene and see how it looks after clearing any missing script errors.

1 Like

Have you tried shutting down unity and reopening, has that changed anything?
at first glance doesnt seem to be anything awry with your script.

Thank you

My ball doesn’t move after doing all these same as tutorial. How can i solve it.

can you double check that the script is attached to the player please.
can you also check that the rigidbody component that is on the player does NOT have the ‘isKinematic’ box checked.

are you getting any errors showing in the console?
if that doesnt sort it, can you please post a copy of your PlayerController script so we can have a look (using code tags please to make it easier to read, see sig for help)

Cheers

i have restarted it many times but keeps pulling up this code , normally it will start with no error in vs , but after trying to add it to the player it will pull this code, ive deleted the script started it IN VS over again , tried deleting the project and restarting it

started new project same error???


i tired mono develop same problem

Thank you for the tutorial. Everything works, however I haven’t compiled it into a standalone app. I wanted to know I’d add sound effects for when the ball hits a cube. Perhaps looping background. Just a thought. Thanks again & I look forward to more tutes.

I’ve got a problem with making this simple game work. Every time I try to test my movement script, this pops up in the console: Screenshot by Lightshot

I’m not sure how this is going wrong, but, I have a few ideas of where the problem could be sitting, as seen in these screenshots.

And the mover script is here under this spoiler.
Code (under spoiler to reduce space that has to be scrolled by).

using UnityEngine;
using System.Collections;

publicclassPlayerController:MonoBehaviour{

publicfloatspeed;

privateRigidbodyrb;

voidStart()
{
rb=GetComponent<Rigidbody>();
}

voidFixedUpdate()
{
floatmoveHorizontal=Input.GetAxis("Horizontal");
floatmoveVertical=Input.GetAxis("Vertical");

Vector3movement=newVector3(moveHorizontal,0.0f,moveVertical);

rb.AddForce(movement*speed);
}

Also, while running debug in Monodevelop, this interesting tidbit popped up too: Screenshot by Lightshot.

My canvas is several times bigger than it should be, the bottom right corner of it is at 0, 0, 0, and my text won’t display in game view. Please help, I can’t find anything about this anywhere else.

One thing to bear in mind the filename of the script and the class name within the script must be the same.

so looking at your script the line that reads

public class PlayerController : MonoBehaviour {

so your class name is ’ PlayerController ’ there, so your filename must match this as in ’ PlayerController.cs ’ .

Its the way Monobehaviours/Unity works, so ensure that these are the same, and try and remove and readd this script to the player and test again.

Have a look through the learn site tutorials or some of the live archives for more info
https://unity3d.com/learn/tutorials/topics/audio/sound-effects-scripting?playlist=17096

you could always work through the SpaceShooter tutorial series as SFX is covered in that, again thats on the learn site tutorial section.

Have a look at the UI tutorials here
https://unity3d.com/learn/tutorials/topics/user-interface-ui

theres also a few live hour archived session outlining the UI at the bottom of that page as well that might help give an outline.

Sent you a PM to try something out.

Hi,

I am a total noob.

I am wondering where can i find the asset for the tutorial provided by unity. If roll a ball is the tutorial, where can i find the asset of it?

This is the error code i get after assigning a playercontroler script… need help in fixing this NullReferenceException: Object reference not set to an instance of an object PlayerController.FixedUpdate () (at Assets/Scripts/PlayerController.cs:19)

Hi, I’m a bit confused, mixed up new knowledge; I’m currently working now with space shooter; I’m just here to ask…

What’s the difference between other.gameObject.CompareTag(" “) and other.CompareTag(” ")?
Same apply with other.gameObject.tag == " " and other.tag == " "?
Are they the same?