public void OnPointerUp(PointerEventData eventData) { if (PlayerInstance.getInstance().IsOnPlatform) { // choosing next platform position if (PlayerInstance.getInstance().transform.position.y > PlatformsController.CurrentPlatform.transform.position.y) { PlayerInstance.getInstance().transform.SetParent(PlayerInstance.getInstance().MyParent); PlatformsController.CurrentPlatform.NextPos = PlatformsController.CurrentPlatform.Positions[rand.Next(PlatformsController.CurrentPlatform.Positions.Count)]; PlatformsController.CurrentPlatform.HasPlayerOn = false; PlatformsController.CurrentPlatform.IsOnJumpPos = false; PlatformsController.CurrentPlatform.Collider.isTrigger = true; } rulesPanel.SetActive(false); } touchLength.Stop(); PlayerInstance.getInstance().Jump(touchLength.ElapsedMilliseconds); touchLength.Reset(); if (PlatformsController.CurrentPlatform != null) { PlatformsController.CurrentPlatform.Collider.isTrigger = true; } }
void FixedUpdate() { if (!PlayerInstance.getInstance().IsOnGround&& rb.velocity == Vector2.zero) { rb.velocity = new Vector2(0f, MOVE_FORCE); } }
public static void ChangeCharacter(string newCharacterTag) { EventsController.RemoveFromFreezable(PlayerInstance.getInstance()); Destroy(PlayerInstance.getInstance().gameObject); foreach (var character in charactersList) { if (character.tag == newCharacterTag) { GameObject newCharacter = Instantiate(character, startPosition, Quaternion.identity); PlayerInstance.setInstance(newCharacter.GetComponent <PlayerBehaviour>()); EventsController.AddToFreezableItems(newCharacter.GetComponent <PlayerBehaviour>()); break; } } }