Reputation: 101
I am new to Unity.While i am following the video tutorial of "Catch Game".. I am using the unity 4.3.3 version.
here is my code.
using UnityEngine;
using System.Collections;
public class BasketController : MonoBehaviour {
public Camera cam;
// Use this for initialization
void Start () {
if (cam == null)
{
cam = Camera.main;
}
}
// Update is called once physics TimeStep
void FixedUpdate () {
Vector3 rawPosition = cam.ScreenToWorldPoint (Input.mousePosition);
Vector3 targetPosition = new Vector3 (rawPosition.x, 0.0f, 0.0f);
rigidbody2D.MovePosition (targetPosition);
}
}
I am getting the following error.
error CS1061: Type `UnityEngine.Rigidbody2D' does not contain a definition for `MovePosition' and no extension method `MovePosition' of type `UnityEngine.Rigidbody2D' could be found (are you missing a using directive or an assembly reference?)
Kindly correct my error.Thanks in advance..
Upvotes: 1
Views: 1250
Reputation: 3615
You need to have Unity 4.5 or newer to use Rigidbody2D.MovePosition: http://forum.unity3d.com/threads/cannot-figure-out-my-error.253139/
As workaround you could probably use:
rigidbody2D.position = targetPosition;
Upvotes: 4