#hm it still doesn t work

1 messages · Page 1 of 1 (latest)

mint fiber
#

Hmm...

#

just in inspect?

#

try setting the variable public and set it in inspect. It really should work with that.

variable1 public and set in inspect

script 2 access script 1 variable and change it at start

sullen sleet
#

hold on

mint fiber
#

in script 2. at start. You reference script 1 right?

#

have you referenced it in the inspector?

#

Show me a pic of the script in inspector

sullen sleet
mint fiber
#

hmm

#

wait I'll write code for you

peak cypress
sullen sleet
peak cypress
#

They're both 0

mint fiber
#

just

peak cypress
#

that seems right

mint fiber
#

change ammo is flying

#

if thats var 1

#

to different

sullen sleet
mint fiber
#

and when game starts it'll be the value of ammo is flying

#

if its 0 var 2 will also be 0

sullen sleet
#

these are the scripts ingame

#

ammoflying (Var2) isn't changing to 1

#

it stays at 0

#

hold on

peak cypress
sullen sleet
#

oh wait

mint fiber
#
private class Ammo() {
   //Set in inspector
   private float variable1;
}

And the second

private class AmmoRotation() {
   //Set in inspector
   public float variable2;

   //reference to script
   public Ammo ammoScipt;
   
   private void SyncVariables() {
      variable2 = ammoScript.variable1;
   }
}
#

YOU DIDN'T PUT IT IN UPDATE?!

#

i will cry. These functions go into update btw

#

update returns each fram

#

Awake and Start at beginning

peak cypress
#

Also this is wholly unnecessary. Why even have var2 at all

mint fiber
#

only once

peak cypress
#

Just use the var from the reference

sullen sleet
mint fiber
#

just reference var1

#

yeah

#

just get var1

#

use var1

sullen sleet
#

now it works

peak cypress
#

Just remove Ammo Is Flying as a variable, and use Ammo.AmmoFlying instead

mint fiber
#

well. idk what your gon do with that but cool

#

use camel case haha

#

it's amazing

#

I suggest you take a video on UNITY BASICS

#

it'll get you comfortable with the framework

#

Ok... Close thread?

#

lmk when to do

sullen sleet
mint fiber
#

ohhh kk

peak cypress
mint fiber
#

it's simple really. watch brackeys C# tutorial

#

it'll help you a ton

sullen sleet
#

but anyways thnx for the help

mint fiber
#

np

sullen sleet
#

now I need to fix the 2 last problems and it's finished