Question by
Adrian-Salarda · Mar 30, 2016 at 03:10 PM ·
script errorvector2getmousebutton
Unity Error Script Vector2
Just creating a function that when GetMouseButton (0) is called it will transform the bullet prefab. However I'm currently getting this specific error
Assets/Scripts/Mover.cs(20,46): error CS0121: The call is ambiguous between the following methods or properties: UnityEngine.Vector2.operator -(UnityEngine.Vector2, UnityEngine.Vector2)' and
UnityEngine.Vector3.operator -(UnityEngine.Vector3, UnityEngine.Vector3)'
Hope someone could help me, that would be greatly appreciated. Thank you guys! Here's the code
void Update () {
if (Input.GetMouseButton (0)) {
Vector2 speed = Camera.main.ScreenToWorldPoint (transform.position);
Vector2 dir = (Input.mousePosition - speed).normalized;
GetComponent<Rigidbody2D>().AddForce (dir * amount);
}
}
}
Comment