void Move() { Vector2 right = new Vector2(.01f, 0); Vector2 left = new Vector2(-.01f, 0); Vector3 currentpos = transform.position; if (moveRight) { if (currentpos[0] >= 37.0f) { moveRight = false; } else { moveable.Move(right); } } else { if (currentpos[0] <= 25.0f) { moveRight = true; } else { moveable.Move(left); } } }
void Update() { CalculateVelocity(); //HandleWallSliding (); controller.Move(velocity * Time.deltaTime); if (controller.collisions.above || controller.collisions.below) { if (controller.collisions.slidingDownMaxSlope) { velocity.y += controller.collisions.slopeNormal.y * -gravity * Time.deltaTime; } else { velocity.y = 0; } } }