Constant speed

I’m sorry for this really dumb question, but… How do i move a ball in a constant speed? I have a ball that uses gravity and a platform, all that i want to do is move the ball in a constant speed in four directions. I’ve tried to do so…

void Update () {
       
        if(Input.GetKeyDown("up")){
            rb.constraints = RigidbodyConstraints.None;
            rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;
            rb.velocity = new Vector3 (0, 0, speed);
           

        }
        if(Input.GetKeyDown("right")){
            rb.constraints = RigidbodyConstraints.None;
            rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
            rb.velocity = new Vector3 (speed, 0, 0);
        }
        if(Input.GetKeyDown("left")){
            rb.constraints = RigidbodyConstraints.None;
            rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezePositionY;
            rb.velocity = new Vector3 (-speed, 0, 0);
        }
        if(Input.GetKeyDown("down")){
            rb.constraints = RigidbodyConstraints.None;
            rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY;
            rb.velocity = new Vector3 (0, 0, -speed);
          
        }
    }

But the ball gets slower over time.

How do you mean?
Does the ball get slower while holding the key? Or does it get slower after letting go of the key?

Remember you’re using the physics engine, so your ball will be subject to friction and drag. Try setting Drag on the ball to 0. And also try creating Physics Materials for the ball and the platform that has Friction set to 0 (make it like ice)

Holding the key or releasing it does not matter, it gets slower anyway x.x Like it gets an IMPULSE and quickly lose speed. The DRAG is already 0. I’ve tried to use the “zero friction” material, it works very well, but the ball does not ROTATE anymore :confused: (btw, thanks for the help)

EDIT1: I check the speed over the time without the zero friction material and… With ANY speed i put, the ball loses speed until reaches 3.5 and remains at 3.5.

Sorry, don’t know where my brain was when I first replied.

GetKeyDown” is only true for the FRAME that it is pressed, and false afterward. If you need to detect a HELD key, use “GetKey

Yes. Do you have any idea why the problem said in the EDIT1 up there is happen?

Hmmm, not sure. What does it do with the 0 friction physics materials? Have you also tried it without the constraints being set?