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().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
↧