Problem with a script

Hi, i have a problem with the script from minute 25

.

I dont have a “Player” space were to drag the 2D Character Controller.

How to make it appear?

using UnityEngine;
using System.Collections;

public class CRS : MonoBehaviour {
   
    public Transform player;
   
    void Update ()
    {
        Transform.position = new Vector3 (player.position.x + 6, 0, -10);
    }
}

Thanks for helping

Posting a link to the video you’re copying isn’t going to help us tell you what you’re doing wrong.

The video obviously has it right cause it works for them, and if you’d have copied the video correctly, then it would work for you. So the error has to be with your script - my best guess would be you’ve mistyped something.

If you want any more help, you’ll need to post your script (inside Code Tags).

maybe, but i checked a lot of times, so i don’t know what may be the proble

You’re not seeing space to attach the Player because the script is failing to compile.

Line 10 needs to be ‘transform’ not ‘Transform’.

:slight_smile:

Thanks , know i have the PLAYER. I hate those moments when it seamed that i checked it all and there are no mistakes , but they were so visible. Should be more attentive.
And thanks again, you saved me some time

1 Like

HI , i have another problem.I’ve write all scripts, but when the player dies, the game should go on scene 1 " game over scene". , but instead it just pauses the game. Maybe you had some similar problems and you could help me

Are there any error messages in the console?

no

Post the script that your using to handle changing scene on player death.

using UnityEngine;
using System.Collections;

public class GameOverScript : MonoBehaviour {
   
    int score = 0;

    void Start () {
        score = PlayerPrefs.GetInt ("Score") * 100;
    }
   

    void OnGUI () {
       
        GUI.Label (new Rect(Screen.width / 2 - 40, 50, 80, 30), "GAME OVER");
       
        GUI.Label (new Rect(Screen.width / 2 - 40, 300, 80, 30), "Score: " + score);
        if(GUI.Button (new Rect(Screen.width / 2 - 30, 350, 60, 30), "Rentry?"))
        {
            Application.LoadLevel (0);
        }
    }
}

That script seems fine.

Are you sure there are no errors in the console when the game actually pauses? Unity usually pauses when a script has an error.

the code is written that if the character falls down the game pauses automatic. The problem is that know it should show the “game over and score” after the character dies

i checked already some times , there are no errors

Ah ok, I think I understand now.

What you need to do is place your GameOverScript onto an object in the scene and enable it when your player dies. The tutorial on Enabling and Disabling Components has an example of how to get scripts to communicate in this way.

sounds to complicate for me

thanks anyway

i resolved the problem. The code was without an error, i just forgot to put the gameoverscript into the main camera of scene 1