So this is the code , and the message i get is 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)'
using UnityEngine;
using System.Collections;
public class ball : MonoBehaviour {
private Paddle paddle;
private Vector3 paddleToBallVector;
private bool hasStared = false;
// Use this for initialization
void Start () {
paddle = GameObject.FindObjectOfType();
paddleToBallVector = this.transform.position - paddle.transform.position;
print (paddleToBallVector);
}
// Update is called once per frame
void Update () {
if (!hasStared) {
this.transform.position = paddle.transform.position + paddleToBallVector;
}
if (Input.GetMouseButtonDown(0)) {
print ("Left mouse Clicked, Launch ball");
hasStared = true;
this.GetComponent().velocity = new Vector2 (3f, 7.5f);
}
}
void OnCollisionEnter2D (Collision2D collision){
//Ball does not trigger sound when brick is destroyed
//Not 100% sure why, possibliy because there isnt a brick
Vector2 tweak = new Vector2 (Random.Range(0f,0.2f), Random.Range(0f,0.2f));
if ( hasStared) {
GetComponent().Play();
GetComponent().velocity += tweak;
}
}
}
console error:
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)'
↧