void RecalculateNavMesh() { foreach (GameObject go in navMeshAreas) { CollisionCounter cc = go.GetComponent <CollisionCounter>(); cc.SetNavMeshArea(this.FindNavMeshArea(cc.GetDencity())); } this.gameObject.GetComponent <NavMeshSurface>().BuildNavMesh(); this.gameObject.transform.position = new Vector3(this.gameObject.transform.position.x, -0.075f, this.gameObject.transform.position.z); agents = GameObject.FindGameObjectsWithTag(Const.tagAGENT); foreach (GameObject go in agents) { // Debug.Log("found agent"); BaseAIBehaviour bab; bab = go.GetComponent <BaseAIBehaviour>(); if (bab) { // Debug.Log("found bab"); bab.ResumeMovement(); } } }
public static CollisionCounter GetCollisionCounter() { const string TAG = "CollisionCounter"; CollisionCounter foundCmp = GameObject.FindGameObjectWithTag(TAG).GetComponent <CollisionCounter>(); INFORM_NOT_FOUND(foundCmp, TAG); return(foundCmp); }
void CreateCube(string name, string color, bool gravity) { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube); go.name = name; //go.transform.parent = transform; go.transform.localPosition = Vector3.zero; go.transform.localScale = new Vector3(_scaleFactor, _scaleFactor, _scaleFactor); go.GetComponent <BoxCollider>().material = this.GetComponent <MeshCollider>().material; Rigidbody rb = go.AddComponent <Rigidbody>(); rb.useGravity = gravity; Vector3 random = new Vector3(Random.Range(-_velocity, _velocity), Random.Range(-_velocity, _velocity), Random.Range(-_velocity, _velocity)); rb.velocity = random; //get the color and create the material Material mat = new Material(baseMat); mat.color = HexToColor(color); genMaterials.Add(mat); //colliderTest CollisionCounter colCount = go.AddComponent <CollisionCounter>(); //add UI Jazz GameObject text = new GameObject(); text.name = "Text"; text.transform.parent = canvas.transform; Text txt = text.AddComponent <Text>(); txt.font = defaultFont; ObjectGUI oUI = text.AddComponent <ObjectGUI>(); oUI.followedObject = go; oUI.cc = colCount; go.GetComponent <MeshRenderer>().material = mat; genObjects.Add(go); }
private void Start() { playerMovement = Global.Component.GetPlayerMovment(); colCounter = Global.Component.GetCollisionCounter(); }
private void Start() { playerMovement = Global.Obj.GetPlayerGameObject().GetComponent <PlayerMovement>(); colCounter = Global.Component.GetCollisionCounter(); }