So i'm not the best at c# where i get a bit confused at is a class inside the main class such as
Now where i'm confused is how can i get the plane entity from the main class to be access in the Player class.Code:class Tsuntest : RustPlugin { //a megafuckton of things that have to do with other things such as the plane. // BaseEntity plane = stuff; etc etc class Player : MonoBehaviour{ public BasePlayer player; public bool inplane; public BaseEntity planeentity; } }
TLDR i want the planeentity to equal plane, but when i tried player.gameObject.AddComponent<Player>().planeentity= plane; that didn't work at all.
Getting variable from sub class?
Discussion in 'Rust Development' started by ツンデレラ, Apr 23, 2017.
-
Code:
var component = player.gameObject.AddComponent<Player>(); component.planeentity = plane;
-
Why would this not work
Code:var component = player.gameObject.AddComponent<Player>(); component.planeentity = plane; rust.RunServerCommand("say "+player.gameObject.AddComponent<Player>().planeentity+" / "+plane);
Code:var component = player.gameObject.AddComponent<Player>(); component.planeentity = plane; rust.RunServerCommand("say "+component.planeentity+" / "+plane);
-
Code:
player.gameObject.AddComponent<Player>(); // Adds the component to the player Player component = player.gameObject.AddComponent<Player>(); // Same as above but gives your a reference to that component component.planeentity = plane; // Set the field for the specified component, in this case a plane
Code:var component = player.gameObject.AddComponent<Player>(); component.planeentity = plane; rust.RunServerCommand("say "+player.gameObject.AddComponent<Player>().planeentity+" / "+plane);
-
-