Hello,
Here is a gif of what my issues is:
link:View GiF
As you can see on click I spawn in a prefab which has a RigidBody2d and a circle collider 2d. It expands until you release the click and then drops down. I have borders which stop the circles from falling out of camera but they dont seem to collide with my circles when I’m dragging them.
Here is my code for dragging, spawning and expanding the circle and the script is attached to the camera:
function Start() {
}
var objectToInstantiate: GameObject;
private
var myCurrentObject: GameObject;
function Update() {
if (Input.GetMouseButtonDown(0)) {
myCurrentObject = Instantiate(objectToInstantiate, Camera.main.ScreenToWorldPoint(Input.mousePosition), Quaternion.identity);
}
if (Input.GetMouseButton(0) && myCurrentObject) {
myCurrentObject.transform.position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
myCurrentObject.transform.position.z = 0;
myCurrentObject.transform.localScale += new Vector3(0.1F, 0.1F, 0);
}
if (Input.GetMouseButtonUp(0) && myCurrentObject) {
myCurrentObject = null;
}
}
I hope this all makes sense, Thanks in advance!