void Start() { if (!ENABLED) { return; } GameObject gameObject = GameObject.Find("Game"); _game = gameObject.GetComponent <DonkeyKongGame>(); _capsule = this.transform.Find("Capsule").gameObject; CollisionHelper col = _capsule.GetComponent <CollisionHelper>(); col.OnEnter += OnCollisionHelperEnter; col.OnExit += OnCollisionHelperExit; _collisionHelper = GroundCollider.GetComponent <CollisionHelper>(); _collisionHelper.IgnoreObjects.Add(this.gameObject); _collisionHelper.IgnoreObjects.Add(this.transform.Find("Capsule").gameObject); _collisionHelper.OnEnter += OnGroundCollisionEnter; _collisionHelper.OnExit += OnGroundCollisionExit; _clickHelper = this.transform.gameObject.GetComponent <ClickHelper>(); _clickHelper.OnMouseDown += OnMouseDown; _clickHelper.ClickObjectNames.Add("Hammer"); _clickHelper.ClickObjectNames.Add("HammerHead"); _hands = this.transform.gameObject.GetComponent <VRHands>(); _hands.OnLeftHandGrabbed += OnLeftHandGrabbed; _hands.OnRightHandGrabbed += OnRightHandGrabbed; _climber = this.transform.gameObject.GetComponent <PlayerClimber>(); }
/// <summary> /// Creates the specified object for the player attached to this object /// </summary> /// <param name="prefab">The prefab to instantiate</param> /// <param name="position">The location at which to spawn the item</param> /// <param name="characterIndex">The index of the selected character</param> /// <param name="playerIndex">The index of the player</param> /// <param name="id">ID of the profile</param> /// <returns>The transform that was created</returns> public override Transform Spawn(Transform prefab, Vector3 position, int characterIndex, string playerName, int playerIndex, Guid id) { base.Spawn(prefab, position, characterIndex, playerName, playerIndex, id); // create the player display var player = Instantiate(prefab, position, Quaternion.identity); // set the height of the object SetHeight(player, characterIndex); // use the correct animation controller SetAnimation(player, characterIndex); // get the jump script _climber = player.GetComponent <PlayerClimber>(); _climber.Initialise(playerIndex, playerName, IncreasePowerUpLevel, ClearPowerUpLevel, DecreasePowerUpLevel); return(player); }