public override bool AIHop(Vector2 target) { //Returns true if you've passed the target if(goingRight && transform.position.x > target.x) { goingRight = false; //Set to false to account for when the wanderTarget moves to the other side of me return true; } else if (goingLeft && transform.position.x < target.x) { goingLeft = false; //Set to false to account for when the wanderTarget moves to the other side of me return true; } CompareTargetPosition(target); if(!jumpController.isJumping) { moveState = PlatformingState.running; } if(sensory.isGrounded && moveState == PlatformingState.running) { moveState = PlatformingState.jumping; jumpController.DumbJump(new Vector2(hopDistance.x * (goingRight ? 1f : -1f), hopDistance.y)); } return false; }
public override void AIMove(Vector2 target) { CompareTargetPosition(target); float xMove = 0; float yMove = 0; if(moveState == PlatformingState.running) { if (goingLeft) xMove = -moveSpeed * Time.deltaTime; if (goingRight) xMove = moveSpeed * Time.deltaTime; } if(moveState == PlatformingState.jumping) { //I have a force on me, so I'm not doing much right now if(!jumpController.isJumping) { moveState = PlatformingState.running; } } Vector2 moveTo = new Vector2(xMove, yMove); transform.Translate (moveTo); }
public void WaypointJump(Vector2 jumpDistance) { if( sensory.isGrounded) { moveState = PlatformingState.jumping; jumpController.SmartJump(jumpDistance); } }
void Start() { sensory = gameObject.GetComponent<AnimalSensory>(); moveSpeed = 5f; // The amount of unity units I move each frame moveState = PlatformingState.running; jumpController = gameObject.GetComponent<JumpController>(); }