Why is this AddForce Error coming up?

I am trying to complete my enemy animation for the opposite AI to move towards my player but Monodevel keeps popping up with this error message.


using UnityEngine;
using System.Collections;

public class AI1 : MonoBehaviour {

private Vector3 Player;
private Vector2 Playerdirection;
private float Xdif;
private float Ydif;
private float speed;

void Start (){
	speed = 10;
}

void Update () {
	Player = GameObject.Find ("Player").transform.position;

	Xdif = Player.x - transform.position.x;
	Ydif = Player.y - transform.position.y;

	Playerdirection = new Vector2 (Xdif, Ydif);

	GetComponent<Rigidbody2D>().Addforce (Playerdirection.normalized * speed);

ERROR: Assets/Scripts/AI1.cs(24,45): error CS1061: Type UnityEngine.Rigidbody2D' does not contain a definition for Addforce’ and no extension method Addforce' of type UnityEngine.Rigidbody2D’ could be found (are you missing a using directive or an assembly reference?)

Any suggestions?

Thanks,
Confused

The method you want is “AddForce”, not “Addforce”. Notice the capital “F”.

It’s AddForce with a capital F. That might be your issue :smiley: