private void Init() { //get snap if (this.gameObject.GetComponent <SnapTest2>() != null) { snapRef = this.gameObject.GetComponent <SnapTest2>(); } else { snapRef = this.gameObject.AddComponent <SnapTest2>(); } //not trigger this.gameObject.GetComponent <Collider>().isTrigger = false; //default is dropping if (plankState == PlankState.beingplaced) { PlacingPlank(); } else if (plankState == PlankState.held) { //PickUpPlank(); print("somethign wroong: initialized as held"); } else if (plankState == PlankState.dropped) { DropPlank(); } else if (plankState == PlankState.placed) { PlacePlank(); } }
private GameObject FindClosestEndNode(GameObject fallingPlank) { SnapTest2 nodeRef = fallingPlank.GetComponent <SnapTest2>(); if (Vector3.Distance(nodeRef.nodes[0].transform.position, player.transform.position) <= Vector3.Distance(nodeRef.nodes[nodes.Length - 1].transform.position, player.transform.position)) { return(fallingPlank.GetComponent <SnapTest2>().nodes[0]); } else { return(fallingPlank.GetComponent <SnapTest2>().nodes[nodes.Length - 1]); } }
public void Init() { //get snap if (this.gameObject.GetComponent <SnapTest2>() != null) { snapRef = this.gameObject.GetComponent <SnapTest2>(); } else { snapRef = this.gameObject.AddComponent <SnapTest2>(); } //get anim if (this.gameObject.GetComponent <PlankAnim>() != null) { plankAnim = this.gameObject.GetComponent <PlankAnim>(); } else { plankAnim = this.gameObject.AddComponent <PlankAnim>(); } plankAnim.SetPlankManager(this); //not trigger this.gameObject.GetComponent <Collider>().isTrigger = false; //default is dropping if (plankState == PlankState.beingplaced) { PlacingPlankCall(); } else if (plankState == PlankState.held) { //PickUpPlankCall(playerWhoPlacedMe.gameObject); //print("somethign wroong: initialized as held"); } else if (plankState == PlankState.dropped) { DropPlank(); } else if (plankState == PlankState.placed) { PlacePlank(); } //ignore collision with player char cont but not collider /*Physics.IgnoreCollision(this.gameObject.GetComponent<Collider>(), GameManager.S.player1.GetComponent<CharacterController>(), true); * Physics.IgnoreCollision(this.gameObject.GetComponent<Collider>(), GameManager.S.player2.GetComponent<CharacterController>(), true); * * if(GameManager.S.player3 != null) * { * Physics.IgnoreCollision(this.gameObject.GetComponent<Collider>(), GameManager.S.player3.GetComponent<CharacterController>(), true); * * if (GameManager.S.player3 != null) * { * Physics.IgnoreCollision(this.gameObject.GetComponent<Collider>(), GameManager.S.player4.GetComponent<CharacterController>(), true); * } * } */ }