- Home /
 
 
               Question by 
               ExelentCoin2044 · Nov 13, 2018 at 07:50 PM · 
                rigidbody2daddforcerigidbody.addforce  
              
 
              Trying to move a character using addforce
I am trying to make a 2d game for fun, but I ran into a problem. This is the script I am using to move and jump. When I try to move it doesn't do anything. I debugged the Vector2 move and it seems to be fine. I don't know what is happening. Can someone please help me?
Script: using System.Collections; using System.Collections.Generic; using UnityEngine;
 public class PlayerMovement : MonoBehaviour {
 
     public Rigidbody2D rb;
 
     public float runSpeed;
     public float jumpForce;
     bool isGrounded = true;
 
     Vector2 jump;
     Vector3 move;
 
     void Start () {
         jump = new Vector2(0, 1f);
     }
 
     // Update is called once per frame
     void Update () {
         float moveHorizontal = Input.GetAxis("Horizontal") * runSpeed;
         move = new Vector3(moveHorizontal, 0);
     }
 
     private void OnCollisionEnter2D()
     {
         isGrounded = true;
     }
 
     void FixedUpdate () {
         //transform.Translate(move * Time.fixedDeltaTime);
         rb.AddForce(move, ForceMode2D.Force);
         if (Input.GetButtonDown("Jump") && isGrounded)
         {
             rb.AddForce(jump * jumpForce, ForceMode2D.Impulse);
             isGrounded = false;
         }
     }
 }
 
               this is a link to the player inpector. /storage/temp/127704-screenshot-3.png
 
                 
                screenshot-3.png 
                (242.2 kB) 
               
 
              
               Comment
              
 
               
              Answer by hectorux · Nov 13, 2018 at 09:45 PM
I think it is due you have constrained the X rigidbody physics so the add force wont do anything
Ow wow thanks I will try it later. It goes deel logical to me.
Your answer