Cooperative controllers are designed to force a group of N mobile agents with limited communication using only relative position between the agents to form a desired formation structure. The centre of the formation structure is the mean position of all the agents. The agents are stabilised at desired positions with respect to the centre of the structure. The proposed controllers also preserve initial communication connectivity and guarantees no collisions between the agents. The control design is based on smooth step functions and potential functions. The proposed control design is applied to solve gradient climbing and target capturing problems in both two- and three-dimensional spaces. The gradient average of a distributed field in nature or artificially generated by a target is first estimated over a bounded region using the field measurement by the agents. The gradient average is then used as the reference velocity to guide the agents.