Hi,
So I’ve got this gameobject which is rotating on itself in the Y axis, from 0 to 180 degrees.
Inside this gameobject, I’v got two quads (QuadA, quadB).
|…| : Gameobject in 3D
|…|
|…| _ | : Quad A
|…| _
| _______ |_ _ | : Quad B
Once flipped 180°:
…__________
…|…|
.|…|
|_ |…|
| …|
| _|________|
When I hit the screen, I check both distances with the 2 quads to see if the hit point is near enough the two of them in 2D space.
float distance1 = Vector2.Distance(hitscreenPosition_on2D, new Vector2(quadA.position.x,quadA.position.y);
float distance2 = Vector2.Distance(hitscreenPosition_on2D, new Vector2(quadB.position.x,quadB.position.y);
Problem : When I hit the screen between the two quads I obtain a distance1 = distance 2 = 2.0f (it’s an example, don’t remember the exact number). but after the rotation I obtain distance1 = distance2 = a different float, bigger.
That’s why I’m thinking the world position given for QuadA and B after their rotation is not good.
Any idea why ?
Erm… the position is “not good”? What does this mean? Can you provide a screenshot of what’s happening?
I’m assuming the quadA and quadB variables are referencing the Transform component of each of the child quads. Did you copy and paste this code or write it in the forum editor? “new vector2” wont work, Vector2 is capitalised.
This could be a number of things. I can’t help without more information.
Hi, it’s not a copy paste, I’ve written that by memory and like I was very tired (and still are), it’s a short bit of code but probably full of mistakes. Sorry about this, I’m going to correct that.
When I say position is “not good”, it means the world positions given for QuadA and B are probably wrong once their parent have rotated.
When I click between them before the gameobject has rotated it’s ok : the distance obtained is small enough. But once it has rotated, it’s no more ok : the distance given is bigger now.
It should not and it appears like a real mystery to me.
IRotations do odd things, or rather things I still don’t get well. Can’t work on it now, I’ll take screenshots, give more infos or maybe a solution as soon as I can.
Ok, forget this thread. I was too tired when I started it.
The problem was with my hit point.
I was using the wrong camera with my cam.ScreenToWorldPoint() …
There’s no problem at all with the positions of the Quads now.