Answer by fredpointzero
There are several places where you can have a null reference : if hit is null => "if(hit.name == "tum1-2")" if "Respawn" is not found, objRespawn will be null and then "objRespawn.GetComponent" will...
View ArticleAnswer by fredpointzero
var LookAtTarget : Transform; var bulletPrefab : Transform; var damp = 6.0; var shootDelay :int = 2; var lastShootTime :int = 0; var shootingForce = 1000; function Update () { if(LookAtTarget != null)...
View ArticleAnswer by fredpointzero
I use the following pattern for my properties in C# : // This is editable through Unity's inspector [SerializeField] private int InternalMyVar = 5; public int MyVar { get { return InternalMyVar; }...
View ArticleAnswer by fredpointzero
You cannot access to the other variable as it is a local variable of the OnTriggerEnter method. you should do the following : * use a TargetComp var to store the component attackRTriggerStay (it seems...
View ArticleAnswer by fredpointzero
Just checkout the [Monobehaviour][1] reference at unity3d.com:> Note: The checkbox for disabling a MonoBehavior (on the editor) will only prevent Start(), Awake(), Update(), FixedUpdate(), and...
View ArticleAnswer by fredpointzero
There are two solutions based on where you draw your GUI. On the right hand, you draw your GUI in one script, so the depth order is defined by the order of the call of GUI / GUILayout functions. To...
View ArticleAnswer by fredpointzero
`transform.right`will shoot at the right direction of your shooter, and that's not what you want. Try this: public var ebullet:Transform; public var projectileSpeed:float = 0.0; public var delay:float...
View ArticleAnswer by fredpointzero
I found the answer : use the attribute NonSerialized and pay attention to which fields are for the editor !
View ArticleAnswer by fredpointzero
To search your scenes in your project's folder, use this : private static void RefreshScenes() { ScenesFileInfo = (new DirectoryInfo(Application.dataPath)).GetFiles("*.unity",...
View ArticleAnswer by fredpointzero
I have two points to say about your code. The first point concerns the method OnCollisionEnter : it takes a Collision object. The second point is that you know which object to destroy, so why don't you...
View ArticleAnswer by fredpointzero
Why don't you use a [ScriptableObject][1] ? They are intented to store data as an assets. You will use unity's way to manipulate data (it will be easier). To then load it at run time, either use a...
View ArticleAnswer by fredpointzero
You can use the [XmlTextReader][1] from C# libs to read your file, or you can create a C# class and deserialize the class with [XmlSerializer][2]. [1]:...
View ArticleAnswer by fredpointzero
Hi, You are probably compiling a dll with Visual Studio 2010 (or newer). Its compiler generate code for your events (add and remove properties), involving a call to...
View Article
More Pages to Explore .....