How to make an object jump continuously?

I am new to unity and I want to create an object which will keep going up and down continuously. I want to know how to write a C# script to create it.
Thank you.,I am new to unity and I want to create an object that keep going up and down continuously (as an obstacle ). I want to know how to write a C# script for the above purpose.

Hi :slight_smile:
There is several options. If your object is moving only in Y axix you can try something like this. This most basic movement up and down (this is not exactly a jump) after that you can add collider to your object and then interact with him. Second why (little bit more complex) is to add Rigidbody to it and then use rigidbody.AddForce() for example. If this script below doesnt help you I will write you another one with Rigidbody.

public class PingPong : MonoBehaviour {

	void Update ()
    {
// In Math.PingPong() number 3 is y axix value. In this case your object will go from 0 to 3 (in Y axis) and then back
        transform.position = new Vector3(transform.position.x, Mathf.PingPong(Time.time, 3), transform.position.z);

	}
}