title: Object won fall of the platform in Unity
body: <p>So i made an ball(player) which moves forward on it's own with script. I want to make that ball act like a normal ball. when it riches the edge of platform it won't fall off. Basicaly it stops on the edge. Here's my image:</p>
  <p><a href="https://i.stack.imgur.com/1iukr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1iukr.png" alt="enter image description here" /></a></p>
  <p>Here's my controller script:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class SwerveInputSystem : MonoBehaviour
  {
  
      private float _lastFrameFingerPositionX;
      private float _moveFactorX;
      public float MoveFactorX =&gt; _moveFactorX;
  
  
      void Start(){
      }
  
      // Update is called once per frame
      void Update()
      {
          if (Input.GetMouseButtonDown(0))
          {
              _lastFrameFingerPositionX = Input.mousePosition.x;
          }
          else if (Input.GetMouseButton(0))
          {
              _moveFactorX = Input.mousePosition.x - _lastFrameFingerPositionX;
              _lastFrameFingerPositionX = Input.mousePosition.x;
          }
          else if (Input.GetMouseButtonUp(0))
          {
              _moveFactorX = 0f;
          }
      }
  }
  </code></pre>
  <p>This is Second script:</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class PlayerController : MonoBehaviour{
      
      private SwerveInputSystem _swerveInputSystem;
      [SerializeField] private float swerveSpeed = 5f;
      [SerializeField] private float maxSwerveAmount = 1f;
      [SerializeField] private float verticalSpeed;
  
      void Start(){
  
          _swerveInputSystem = GetComponent&lt;SwerveInputSystem&gt;();
      }
  
  
      void Update(){
          float swerveAmount = Time.deltaTime * swerveSpeed * _swerveInputSystem.MoveFactorX;
          swerveAmount = Mathf.Clamp(swerveAmount, -maxSwerveAmount, maxSwerveAmount);
          transform.Translate(swerveAmount, 0, 0);
          float verticalDelta = verticalSpeed * Time.deltaTime;
  
          transform.Translate(swerveAmount, verticalDelta, 0.1f);
      }
  }
  </code></pre>