onMouseUp 2D Issues
This seems to be a common issue with 2D colliders, but onMouseUp() isn't working at all. I've tested it with a Collider2D, a 3D Collider, an orthographic camera and a perspective camera, I've created code to make sure raycast hits the object (it does). I have the object in the scene with the script attached to it that has the void onMouseUp() function. I've also heard that moving the object closer to the camera helps, but it doesn't. There's nothing between the camera and the object.
public Collider coll;
void Start() {
coll = GetComponent<Collider>();
}
void Update() {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if (coll.Raycast (ray, out hit, 100.0F)){
transform.position = ray.GetPoint (100.0F);
}
Debug.Log("hey");
}
}
void onMouseOver(){
if(Input.GetMouseButtonUp(0)){
Debug.Log("yo");
}
}
public void onMouseUp(){
Debug.Log ("hi");
}
These are the functions I have running on my object. Commenting out any combination of them doesn't solve the problem.
Your answer
Follow this Question
Related Questions
hit normal vector from raycast is always [-1,0], which makes slope angle 90 1 Answer
How do you make one game object follow the shape of another game object? 0 Answers
NullReferenceException: Object Reference not set to an instance of an object 0 Answers
Raycast calls sometime passing through Collider2D's points 1 Answer