Hi there,
First post on the Unity-forums - and I’m just trying to figure it all out… This one I couldn’t find anything about - so hopefully you guys can help me.
I have a sprite falling from the sky - when i click it I want it to bounce depending on where I clicked it. Clicking more left on the sprite would make it bounce back up towards the right - and vise versa.
Must admit that I’m out of ideas. I’ve found the location I click with the mouse using:
Input.mousePosition.x/.y
And the location of the sprite by using:
Vector3 pos2d = GameObject.Find("MainCamera").camera.WorldToScreenPoint(rigidbody2D.transform.position);
Using this I had hoped I could figure out in what percentage of the sprite I was clicking - but without knowing the pixel-size of the Collider2D - I don’t think I can do it that way.
I’m still trying to wrap my head around the raycast-stuff and all that, and the answer might lay there somewhere - but I’m on deep waters here
Anyone who can give me a little hint (C#)?
Thanks in advance.
// Yoc.