Can't get player object to move

I’m having problems getting my player obj. to move. I’m making an infinite runner game, got the script written, but I get two errors, not sure what is wrong, here’s the two errors

  1. (24,45)error CS1501: No overload for method AddForce' takes 2’ arguments
  2. (37,37)error CS1501: No overload for method AddForce' takes 4’ arguments

Here’s my script

using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour {

	public static float distanceTraveled;

	public float acceleration;
	public Vector3 jumpVelocity;
		
	private bool touchingPlatform;
	//private Vector3 startPosition;
	
	//void Start () {
		//startPosition = transform.localPosition;
		//renderer.enabled = false;
		//rigidbody.isKinematic = true;
		//enabled = false;
	//}
	
	void Update () {
		if(Input.GetButtonDown("Jump")){
			if(touchingPlatform){
				rigidbody2D.AddForce(jumpVelocity, ForceMode.VelocityChange);
				touchingPlatform = false;
			}

		}
		distanceTraveled = transform.localPosition.x;

		

	}
	
	void FixedUpdate () {
		if(touchingPlatform){
			rigidbody2D.AddForce(acceleration, 0f, 0f, ForceMode.Acceleration);
		}
	}
	
	void OnCollisionEnter () {
		touchingPlatform = true;
	}
	
	void OnCollisionExit () {
		touchingPlatform = false;
	}
	

}

What I’m trying to do is get the player obj to run and jump, with a double jump. The running has to be always going, and jumping with a button press.
Thanks for the help.
I apologize if this has already been asked, I did a search and didn’t find any answers.

You are using Rigidbody.AddForce not Rigidbody2D.AddForce.
ScriptReference

Ok, I read the scriptReference and I took out one of the 0f, and other things and I still get the same errors, I’m not sure how to get it to work. Help would be appreciated.

Thanks.

Learn to understand what your compiler is trying to tell you. The error message says it all, really.

Rigidbody2D.AddForce() only takes one parameter, the force. It doesn’t take a force mode as Rigidbody.AddForce() does. (Well, at least not yet. Hopefully this will be a feature in a future release.)

Long story short: Rigidbody2D.AddForce != Rigidbody.AddForce

The Method takes only one parameter, you are trying to overload it with more than one parameter.

    using UnityEngine;
    using System.Collections;
     
    public class PlayerScript : MonoBehaviour {
     
        public static float distanceTraveled;
     
        public float acceleration;
        public Vector3 jumpVelocity;
           
        private bool touchingPlatform;
        //private Vector3 startPosition;
       
        //void Start () {
            //startPosition = transform.localPosition;
            //renderer.enabled = false;
            //rigidbody.isKinematic = true;
            //enabled = false;
        //}
       
        void Update () {
            if(Input.GetButtonDown("Jump")){
                if(touchingPlatform){
                    rigidbody2D.AddForce(jumpVelocity);
                    touchingPlatform = false;
                }
     
            }
            distanceTraveled = transform.localPosition.x;
     
           
     
        }
       
        void FixedUpdate () {
            if(touchingPlatform){
                rigidbody2D.AddForce(acceleration);
            }
        }
       
        void OnCollisionEnter () {
            touchingPlatform = true;
        }
       
        void OnCollisionExit () {
            touchingPlatform = false;
        }
       
     
    }

Thanks for both of your help, I wasn’t understanding what it was telling me. My errors are gone, now the player just falls off the screen when I hit play.

Here’s what my code now.

using UnityEngine;
using System.Collections;

public class PlayerScript : MonoBehaviour {

	public static float distanceTraveled;

	public Vector2 acceleration;
	public Vector3 jumpVelocity;
		
	private bool touchingPlatform;
	//private Vector3 startPosition;
	
	//void Start () {
		//startPosition = transform.localPosition;
		//renderer.enabled = false;
		//rigidbody.isKinematic = true;
		//enabled = false;
	//}
	
	void Update () {
		if(Input.GetButtonDown("Jump")){
			if(touchingPlatform){
				rigidbody2D.AddForce(jumpVelocity);
				touchingPlatform = false;
			}

	}
		distanceTraveled = transform.localPosition.x;

		

	}
	
	void FixedUpdate () {
		if(touchingPlatform){
			rigidbody2D.AddForce(acceleration);
			//rigidbody2D.velocity = new Vector2(1f, rigidbody2D.velocity.y);
		}
	}
	
	void OnCollisionEnter () {
		touchingPlatform = true;
	}
	
	void OnCollisionExit () {
		touchingPlatform = false;
	}
	

}

When I turn Kinematic on for the Rigidbody2d he doesn’t fall, just stands there with no movement, should this be on or off?

I’m slowly figuring this out.

Let me quote what your bible says about Rigidbody2D.isKinematic:
If this property is set to true then the rigidbody will stop reacting to collisions and applied forces.