can someone tell me why this void onMouseDown isn’t working? I wrote it correctly.
void OnMouseDown()
{
hook = wall.AddComponent(typeof(SpringJoint)) as SpringJoint;
hook.connectedBody = UwU;
Debug.Log(“hook”);
}
Try to write like this:
private void Update
{
if (Input.GetMouseButton(0))
{
hook = wall.AddComponent(
typeof(SpringJoint)) as SpringJoint;
hook.connectedBody = UwU;
Debug.Log("hook");
}
}
Google is your friend:
https://stackoverflow.com/questions/28916663/unity-c-sharp-onmousedown-does-not-work-why
Or you could try Unity.EventSystems, works great whenever I used it.
Have you made sure that the object you want the onMouseDown to work on, has a collider attached to it.
Cause the onMouseMove function won’t work unless a collider is attached to the gameobject