void Awake() { sidePosition = new Vector3(10, 7, 0); abovePosition = new Vector3(0, 10, 0); behindPosition = new Vector3(0, 0, -10); currentCamPosition = CameraPosition.Side; currentMaterial = BallMaterial.Rubber; Size = PlayerSizes.Small; }
void FixedUpdate() { print(currentKey); if(!Input.anyKey) currentKey = KeyCode.None; if(Input.GetKey(KeyCode.PageUp)) { currentKey = KeyCode.PageUp; if(previousKey != currentKey) { if(Size == PlayerSizes.Small) { Size = PlayerSizes.Medium; animation["SmallMed"].speed = 2; animation.Play("SmallMed"); } else if(Size == PlayerSizes.Medium) { Size = PlayerSizes.Large; animation["MedLrg"].speed = 2; animation.Play("MedLrg"); } } } if(Input.GetKey(KeyCode.PageDown)) { currentKey = KeyCode.PageDown; if(previousKey != currentKey) { if(Size == PlayerSizes.Medium) { animation["SmallMed"].speed = -2; animation["SmallMed"].time = animation["SmallMed"].length; animation.Play("SmallMed"); Size = PlayerSizes.Small; } else if(Size == PlayerSizes.Large) { animation["MedLrg"].speed = -2; animation["MedLrg"].time = animation["MedLrg"].length; animation.Play("MedLrg"); Size = PlayerSizes.Medium; } } } previousKey = currentKey; }
private static extern void FCE_Document_SetPlayerSize(PlayerSizes size);
// Update is called once per frame void Awake() { Size = PlayerSizes.Small; }
void ShrinkPlayer() { if(Size == PlayerSizes.Medium) { animation["SmallMed"].speed = -2; animation["SmallMed"].time = animation["SmallMed"].length; animation.Play("SmallMed"); Size = PlayerSizes.Small; } else if(Size == PlayerSizes.Large) { animation["MedLrg"].speed = -2; animation["MedLrg"].time = animation["MedLrg"].length; animation.Play("MedLrg"); Size = PlayerSizes.Medium; } }
void GrowPlayer() { if(isGrounded()) rigidbody.AddForce(Vector3.up); //Add a bit of force to avoid sinking into floor if(Size == PlayerSizes.Small) { Size = PlayerSizes.Medium; animation["SmallMed"].speed = 2; animation.Play("SmallMed"); } else if(Size == PlayerSizes.Medium) { Size = PlayerSizes.Large; animation["MedLrg"].speed = 2; animation.Play("MedLrg"); } }