#my code is not working

1 messages · Page 1 of 1 (latest)

cinder dagger
#

using UnityEngine;

public class EndTrigger : MonoBehaviour{

public Gamemanager GameManager;

void OnTriggerEnter ()
{
    GameManager.CompletedLevel();

}

}

#

im trying to dragg the gamemanager into the public but its not working

edgy surge
#

Do you have any compiler errors or warnings in the Unity console?

cinder dagger
#

im trying to put it in here

cinder dagger
#

but that error has nothing to do with it

#

it has prob to do with this

edgy surge
#

Post error anyway, a single one will prevent the whole project from compiling.

cinder dagger
#

k

#

its just saying object refrence is not set

cinder dagger
edgy surge
#

Alright so it's compiling, as this error can only happen when the game runs

cinder dagger
#

yes

#

that only happens when i start the game

edgy surge
#

So you can't drag-drop?
Where are you dragging from?

cinder dagger
#

im draging from my scripts

edgy surge
#

If it's from the project files (Assets window) that's incorrect

cinder dagger
#

i have all my scripts in a place

#

its assets > scripts

edgy surge
#

You have to attach Gamemanager to an object in the scene to be able to drag-drop it

cinder dagger
#

but every script i use comes from there and i havent had any problems

#

ah k

#

lemme try that

#

wait and how do i do that

#

cuz i dont think i have done that alr

edgy surge
#

It's unlikely, since you have other scripts.
Select the object you want to attach it on in the Hierarchy, and in the Inspector scroll all the way down and click "Add Component"

#

Then use the search bar to select Gamemanager and confirm

cinder dagger
#

i stil cant

#

drag it over there

#

but im pretty sure its something like last time

edgy surge
#

Drag the object you attached the script on now

cinder dagger
#

cuz all the scripts have a different logo with # on and this one doesn

cinder dagger
#

?

cinder dagger
edgy surge
#

If you added it to the same object as EndTrigger, then you can do that yeah

#

From the Hierarchy, drag-drop the object into EndTrigger's exposed field

#

And for the icon that is different, it's because GameManager is a special name Unity recognizes and puts a special icon for it.

cinder dagger
#

it works

cinder dagger
edgy surge
#

Yeah go ahead

cinder dagger
#

its abbout draging something in again

#

i need to drag my level complete screen into there but its not working

edgy surge
#

You added that onto an object in the scene, so drop it onto the GameManager that is on the object in the scene

#

In 98% of the cases you won't be able to drag-drop anything from/to scripts in your Assets

cinder dagger
#

ah okey

#

im so sorry for waisting your time

#

but ty for helping

edgy surge
#

As long as you learn, you're not wasting my time