Question by 
               Thunderstorm24 · Apr 22, 2019 at 06:31 PM · 
                2d2d-physics2d-gameplay  
              
 
              I want a 2d object to move one direction only without clicking a button or anything
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class BrokeEnviroment : MonoBehaviour { public float speed = 1; public float movement = 1; private Rigidbody2D rb;
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent<Rigidbody2D>();
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     rb.AddForce(movement, speed);
 }
 
               }
               Comment
              
 
               
              Answer by Thunderstorm24 · Apr 22, 2019 at 06:51 PM
Nevermind found the solution
using System.Collections; using System.Collections.Generic; using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))] public class BrokeEnviroment : MonoBehaviour {
 public Transform target;
 public float speed = 5f;
 private Rigidbody2D rb;
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent<Rigidbody2D>();
 }
 // Update is called once per frame
 void FixedUpdate()
 {
     rb.velocity = transform.right * speed;
 }
 
               }
Your answer
 
             Follow this Question
Related Questions
How to change viewing direction in 2D mode 0 Answers
Distance Joint 2D with Kinematic Player 2 Answers
2D Weird Jumping 1 Answer
Help 2D Custom HillClimbRacingGame 0 Answers
Getting rid of 2D collision jitter 1 Answer