How to access a variable from another script in unity

preview_player
Показать описание
#game #unity #unity3d #unitytutorials #programming
Рекомендации по теме
Комментарии
Автор

OMG YOU JUST SAVED MY PROJECT! THANK YOU VERY MUCH!!!!

GD_MiT
Автор

ok, it is a damn simple example, but its ok, because lot of beginer dont know how to do it, so somewhere need to start. :) I subscribed, and will check your chanel for more. Now there is only 2 video, but I hope you will make more. :) :)

Ferenc-Racz
Автор

fuckyng i subscribed, and liked every video, i have ben searching for this for hours

goofy
Автор

2hrs of finding solutions and ending up solving it in 47secs

whitdky
Автор

It doesn’t recognise the variable I get error cs1061

SortofGoodwithTech
Автор

im getting an error message. it says
error CS0103: the name 'timeRemaining' does not exist in the current context

does anyone know what i am doing wrong?

brokenfurrytrash
Автор

Thanks but i'm facing an error still, It says object not set to an instance of an object, What should i do?

karlkiyotaka
Автор

i have this error: Assets\movement2.cs(23, 21): error CS0103: The name 'score' does not exist in the current context

sepperaedemaekers
Автор

For me it keeps saying Object refrence not set to an instance of an object when I do it please help

nuggtcraft
Автор

For me i cant refference the other script, do you know How to fix it?

kneip_ask
Автор

THIS DOESNT WORK AFTER 5 HERES MY SCRIPTS im trying to access the bool isPlaneDestroyed; but I cant this is the first script where the main variable is and what I need
"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyPlane : MonoBehaviour
{

public bool isPlaneDestroyed = false;

public ParticleSystem explosionParticles;

public GameObject plane;

public Transform spawnPoint;

public Shake cameraShake;






void OnCollisionEnter(Collision col)
{
if(col.gameObject.tag == "Explodable") {
Debug.Log("Crashed");
Instantiate(explosionParticles, transform.position, Quaternion.identity);
isPlaneDestroyed = true;
}

}


}
"

and then this is the script im not able to access the variable from can you help me?

"using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraActionShaker : MonoBehaviour
{

[SerializeField] DestroyPlane destroy;

destroy.isPlaneDestroyed;


public GameObject plane;


void Start()
{

}


void Update()
{
if (destroy.isPlaneDestroyed = true)
{
Debug.Log("The Plane has SHAKEN Please work plslsss");
StartCoroutine(cameraShake.Shaker(.15f, .4f));
}
}







public Shake cameraShake;






}"

Devsycode