- Home /
Assets/Scripts/connector_link.js(7,29): BCE0051: Operator '-' cannot be used with a left hand side of type 'UnityEngine.GameObject' and a right hand side of type 'UnityEngine.GameObject'. ERROR HELP!
I have this error..... Assets/Scripts/connector_link.js(7,29): BCE0051: Operator '-' cannot be used with a left hand side of type 'UnityEngine.GameObject' and a right hand side of type 'UnityEngine.GameObject'.
This is the code I have so far....
#pragma strict
var v3Start : GameObject;
var v3End : GameObject;
function Start () {
// Position it
transform.position = (v3End - v3Start)/2.0f + v3Start;
var v3T = transform.localScale; // Scale it
v3T.y = (v3End - v3Start).magnitude;
transform.localScale = v3T;
// Rotate it
transform.rotation = Quaternion.FromToRotation(Vector3.up, v3End - v3Start);
}
function Update () {
}
function connect(node1, node2){
//var distance =
//sphere1.transform.scale.x
}
Thanks for any help or suggestions!!! :D
Answer by Bunny83 · Jun 12, 2013 at 03:23 PM
Change your variables to Transform:
var v3Start : Transform;
var v3End : Transform;
Instead of v3End you have to use v3End.position. Same for v3Start.
Don't forget to re-assign your objects.
I fixed that but I have another error.
It says Operator '+' cannot be used with a left hand side of type 'UnityEngine.Vector3' and a right hand side type of 'UnityEngine.Transform'.
What does all of this mean? I am pretty new to coding and Unity in general. Thanks!
As @Bunny83 said - Ins$$anonymous$$d of v3End you have to use v3End.position. Same for v3Start.