void OnTriggerEnter( Collider other ) { var jumpNode = other.GetComponent<JumpNodeTrigger>(); if( jumpNode != null && ignoreJumpNode != jumpNode ) { jumpFunction = jumpNode.CreateJump(); ignoreJumpNode = jumpNode.oppositeTrigger; } }
void onDeath() { jumpFunction = null; ignoreJumpNode = null; }
void onDeath() { jumpFunction = null; ignoreJumpNode = null; localVelocity = Vector3.zero; }
void UpdateJump() { if( jumpFunction.IsDone() ) { jumpFunction = null; } else { transform.position = jumpFunction.UpdateStep(); } }
// Update is called once per frame void Update() { if(jumpFunction != null) { // Continue an automatic jump. if(jumpFunction.IsDone()) { jumpFunction = null; } else { transform.position = jumpFunction.UpdateStep(); } } // Apply velocity. var grounded = characterController.isGrounded; var speed = (grounded ? linearSpeed : airborneLinearSpeed)*Input.GetAxis(movementAxis); if (flipMovementAxis) speed *= -1f; var aSpeed = (grounded ? angularSpeed : airborneAngularSpeed); if (flipRotationAxis) aSpeed *= -1f; transform.Rotate(new Vector3(0f, aSpeed*Time.deltaTime*Input.GetAxis(rotationAxis), 0f)); if (jumpFunction == null) { var ambientVelocity = character.BaseVelocity + localVelocity; Vector3 motion = transform.TransformVector( (ambientVelocity + moveDirection*speed)*Time.deltaTime); if (ambientVelocity.magnitude < 0.01) characterController.SimpleMove(motion); else characterController.Move(motion); } GetComponent<Animator>().SetFloat("Speed", grounded ? Mathf.Abs(speed) : 0f); // Apply accelleration due to gravity. if (grounded && Vector3.Dot(localVelocity, Physics.gravity) > 0) { localVelocity = Vector3.zero; } else { localVelocity += Physics.gravity * Time.deltaTime; } if (Input.GetKeyDown(shootButton1) || Input.GetKeyDown(shootButton2) || Input.GetKeyDown(shootButton3)) { // Effect the shoot button. ProjectileSystem.ShootProjectile( projectilePrefab, projectileTransform.position, projectileTransform.forward, characterController); GameObject.Find("RetroShoot").GetComponent<AudioSource>().Play(); } if (grounded && (Input.GetKeyDown(jumpButton1) || Input.GetKeyDown(jumpButton2) || Input.GetKeyDown(jumpButton3))) { // Effect the jump button. localVelocity += jumpVelocity; GameObject.Find("RetroJump").GetComponent<AudioSource>().Play(); } }