- Home /
 
               Question by 
               abtahitajwar · Apr 02, 2017 at 09:57 AM · 
                physicsrigidbody.addforce  
              
 
              Can't adding Force to move ball Left or Right
I am making a game where a ball moves forward in constant speed and I want to add force to move the ball left or right. But my unity is not adding force after using the AddForce function also Its not showing any arror. Here is my code
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class ballMove : MonoBehaviour {
 
     Rigidbody ballRigidbody;
 
     // Use this for initialization
     void Start () {
         ballRigidbody = GetComponent<Rigidbody> ();
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         ballRigidbody.velocity =  (Vector3.forward * 20);
 
         if (Input.GetKeyDown (KeyCode.A)) {
             ballRigidbody.AddForce (Vector3.left * Time.deltaTime * 10f);
         }
         if (Input.GetKeyDown (KeyCode.D)) {
             ballRigidbody.AddForce (Vector3.left * Time.deltaTime * 10f);
         }
     }
 
 }
Why its not working?
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
add force to object that has 2 different rigid bodies 0 Answers
How to calculate force to apply to move object to a certain distance. 1 Answer
Adding a position offset to a force towards an object 1 Answer
Rigidbody.velocity seems to be breaking jumping physics 0 Answers
Sudden surge of force applied to a rigidbody from continous jumping. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                